File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -10,4 +10,4 @@ add_benchmark(GetIntrinsicForClangBuiltin GetIntrinsicForClangBuiltin.cpp PARTIA
1010add_benchmark(FormatVariadicBM FormatVariadicBM.cpp PARTIAL_SOURCES_INTENDED)
1111add_benchmark(GetIntrinsicInfoTableEntriesBM GetIntrinsicInfoTableEntriesBM.cpp PARTIAL_SOURCES_INTENDED)
1212add_benchmark(SandboxIRBench SandboxIRBench.cpp PARTIAL_SOURCES_INTENDED)
13-
13+ add_benchmark(SparseBitVector SparseBitVector.cpp PARTIAL_SOURCES_INTENDED)
Original file line number Diff line number Diff line change 1+ #include " llvm/ADT/SparseBitVector.h"
2+ #include " benchmark/benchmark.h"
3+ using namespace llvm ;
4+
5+ static unsigned xorshift (unsigned State) {
6+ State ^= State << 13 ;
7+ State ^= State >> 17 ;
8+ State ^= State << 5 ;
9+ return State;
10+ }
11+
12+ static void BM_SparseBitVectorIterator (benchmark::State &State) {
13+ SparseBitVector<> BV;
14+
15+ unsigned Prev = 0xcafebabe ;
16+ for (unsigned I = 0 , E = State.range (0 ); I != E; ++I)
17+ BV.set ((Prev = xorshift (Prev)) % 10000 );
18+
19+ for (auto _ : State) {
20+ unsigned Total = 0 ;
21+ for (auto I = BV.begin (), E = BV.end (); I != E; ++I)
22+ Total += *I;
23+ benchmark::DoNotOptimize (Total);
24+ }
25+ }
26+
27+ BENCHMARK (BM_SparseBitVectorIterator)->Arg(10 )->Arg(100 )->Arg(1000 )->Arg(10000 );
28+
29+ BENCHMARK_MAIN ();
You can’t perform that action at this time.
0 commit comments