Skip to content

Commit

Permalink
Allocate 16k scratch on heap
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Nov 13, 2024
1 parent 096f73a commit 5017390
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tool/speed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1257,17 +1257,19 @@ static bool SpeedHmacOneShot(const EVP_MD *md, const std::string &name,
return true;
}

const size_t SCRATCH_SIZE = 16384;

using RandomFunction = std::function<void(uint8_t *, size_t)>;
static bool SpeedRandomChunk(RandomFunction function, std::string name, size_t chunk_len) {
uint8_t scratch[16384];
bssl::UniquePtr<uint8_t> scratch((uint8_t*)OPENSSL_malloc(SCRATCH_SIZE));

if (chunk_len > sizeof(scratch)) {
if (chunk_len > SCRATCH_SIZE) {
return false;
}

TimeResults results;
if (!TimeFunction(&results, [chunk_len, &scratch, &function]() -> bool {
function(scratch, chunk_len);
function(scratch.get(), chunk_len);
return true;
})) {
return false;
Expand Down

0 comments on commit 5017390

Please sign in to comment.