-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Pull Request resolved: #122 This diff adds benchmarks for the WireKeeper. I opted to not include the batch or arithmetic API (for now at least), since they are implemented the exact same way as the boolean, non-batch API. Reviewed By: chualynn Differential Revision: D35035761 fbshipit-source-id: d28cbfcc53772a9247015f937353be6673c01b1b
- Loading branch information
1 parent
9b6a89f
commit 5e47cbc
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <folly/Benchmark.h> | ||
|
||
#include "fbpcf/scheduler/WireKeeper.h" | ||
|
||
const bool unsafe = true; | ||
|
||
namespace fbpcf::scheduler { | ||
|
||
#define BENCHMARK_WIREKEEPER \ | ||
folly::BenchmarkSuspender braces; \ | ||
auto wireKeeper = WireKeeper::createWithVectorArena<unsafe>(); \ | ||
std::vector<IScheduler::WireId<IScheduler::Boolean>> wireIds; \ | ||
for (auto i = 0; i < n; i++) { \ | ||
wireIds.push_back(wireKeeper->allocateBooleanValue()); \ | ||
} \ | ||
braces.dismiss(); \ | ||
while (n--) | ||
|
||
BENCHMARK(WireKeeperBenchmark_allocateBooleanValue, n) { | ||
folly::BenchmarkSuspender braces; | ||
auto wireKeeper = WireKeeper::createWithVectorArena<unsafe>(); | ||
braces.dismiss(); | ||
|
||
while (n--) { | ||
wireKeeper->allocateBooleanValue(); | ||
} | ||
} | ||
|
||
BENCHMARK(WireKeeperBenchmark_getBooleanValue, n) { | ||
BENCHMARK_WIREKEEPER { | ||
wireKeeper->getBooleanValue(wireIds.at(n)); | ||
} | ||
} | ||
|
||
BENCHMARK(WireKeeperBenchmark_setBooleanValue, n) { | ||
BENCHMARK_WIREKEEPER { | ||
wireKeeper->setBooleanValue(wireIds.at(n), n & 1); | ||
} | ||
} | ||
|
||
BENCHMARK(WireKeeperBenchmark_getFirstAvailableLevel, n) { | ||
BENCHMARK_WIREKEEPER { | ||
wireKeeper->getFirstAvailableLevel(wireIds.at(n)); | ||
} | ||
} | ||
|
||
BENCHMARK(WireKeeperBenchmark_setFirstAvailableLevel, n) { | ||
BENCHMARK_WIREKEEPER { | ||
wireKeeper->setFirstAvailableLevel(wireIds.at(n), n); | ||
} | ||
} | ||
|
||
BENCHMARK(WireKeeperBenchmark_increaseReferenceCount, n) { | ||
BENCHMARK_WIREKEEPER { | ||
wireKeeper->increaseReferenceCount(wireIds.at(n)); | ||
} | ||
} | ||
|
||
BENCHMARK(WireKeeperBenchmark_decreaseReferenceCount, n) { | ||
BENCHMARK_WIREKEEPER { | ||
wireKeeper->decreaseReferenceCount(wireIds.at(n)); | ||
} | ||
} | ||
} // namespace fbpcf::scheduler |