File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,31 @@ static std::string generateBBWalkIR(unsigned Size) {
8989 return SS.str ();
9090}
9191
92+ template <IR IRTy> static void SBoxIRCreation (benchmark::State &State) {
93+ static_assert (IRTy != IR::LLVM, " Expected SBoxTracking or SBoxNoTracking" );
94+ LLVMContext LLVMCtx;
95+ unsigned NumInstrs = State.range (0 );
96+ std::unique_ptr<llvm::Module> LLVMM;
97+ std::string IRStr = generateBBWalkIR (NumInstrs);
98+ LLVMM = parseIR (LLVMCtx, IRStr.c_str ());
99+ llvm::Function *LLVMF = &*LLVMM->getFunction (" foo" );
100+
101+ for (auto _ : State) {
102+ State.PauseTiming ();
103+ sandboxir::Context Ctx (LLVMCtx);
104+ if constexpr (IRTy == IR::SBoxTracking)
105+ Ctx.save ();
106+ State.ResumeTiming ();
107+
108+ sandboxir::Function *F = Ctx.createFunction (LLVMF);
109+ benchmark::DoNotOptimize (F);
110+ State.PauseTiming ();
111+ if constexpr (IRTy == IR::SBoxTracking)
112+ Ctx.accept ();
113+ State.ResumeTiming ();
114+ }
115+ }
116+
92117template <IR IRTy> static void BBWalk (benchmark::State &State) {
93118 LLVMContext LLVMCtx;
94119 sandboxir::Context Ctx (LLVMCtx);
@@ -189,6 +214,16 @@ template <IR IRTy> static void RUOW(benchmark::State &State) {
189214 finalize<IRTy>(Ctx);
190215}
191216
217+ // Measure the time it takes to create Sandbox IR without/with tracking.
218+ BENCHMARK (SBoxIRCreation<IR::SBoxNoTracking>)
219+ ->Args({10 })
220+ ->Args({100 })
221+ ->Args({1000 });
222+ BENCHMARK (SBoxIRCreation<IR::SBoxTracking>)
223+ ->Args({10 })
224+ ->Args({100 })
225+ ->Args({1000 });
226+
192227BENCHMARK (GetType<IR::LLVM>);
193228BENCHMARK (GetType<IR::SBoxNoTracking>);
194229
You can’t perform that action at this time.
0 commit comments