@@ -329,29 +329,32 @@ TEST(ApproximationTest, ThreeQubitRemoveUnconnected) {
329
329
TEST (ApproximationTest, Runtime) {
330
330
{
331
331
constexpr std::size_t n = 15 ; // Up to 16 qubits.
332
+ constexpr std::size_t repeats = 10 ; // Repeat benchmark 10 times.
332
333
constexpr double fidelity = 1 - 0.01 ; // Budget of .02
333
334
334
335
std::array<std::size_t , n> qubits{}; // Qubit counts: [2, 16]
335
336
std::iota (qubits.begin (), qubits.end (), 2 );
336
337
337
338
for (std::size_t i = 0 ; i < n; ++i) {
338
- const std::size_t nq = qubits[i];
339
+ std::size_t nodes{};
340
+ double rt{};
339
341
342
+ const std::size_t nq = qubits[i];
340
343
auto dd = std::make_unique<dd::Package>(nq);
341
344
342
- auto state = generateExponentialDD (nq, *dd);
343
- const std::size_t numNodes = state.size () - 1 ; // Minus terminal.
345
+ for (std::size_t r = 0 ; r < repeats; ++r) {
346
+ auto state = generateExponentialDD (nq, *dd);
347
+ nodes += state.size () - 1 ; // Minus terminal.
348
+
349
+ const auto t1 = std::chrono::high_resolution_clock::now ();
350
+ approximate (state, fidelity, *dd);
351
+ const auto t2 = std::chrono::high_resolution_clock::now ();
352
+ const std::chrono::duration<double , std::micro> runtime = t2 - t1;
344
353
345
- const auto t1 = std::chrono::high_resolution_clock::now ();
346
- approximate (state, fidelity, *dd);
347
- const auto t2 = std::chrono::high_resolution_clock::now ();
348
- const std::chrono::duration<double , std::micro> runtime = t2 - t1;
354
+ rt += runtime.count ();
355
+ }
349
356
350
- std::cout << numNodes << " ;" << runtime.count () << " ;"
351
- << runtime.count () /
352
- (static_cast <double >(numNodes) * std::log2 (numNodes))
353
- << ' \n ' ;
357
+ std::cout << nodes / repeats << " | " << rt / repeats << ' \n ' ;
354
358
}
355
- EXPECT_FALSE (true );
356
359
}
357
360
}
0 commit comments