-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_satencoder.cpp
More file actions
81 lines (47 loc) · 1.82 KB
/
test_satencoder.cpp
File metadata and controls
81 lines (47 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "CircuitOptimizer.hpp"
#include "SatEncoder.hpp"
#include "algorithms/RandomCliffordCircuit.hpp"
#include <fstream>
#include <chrono>
#include <fstream>
#include <sys/resource.h>
#include <ctime>
#ifdef _MSC_VER
#define localtime_r(a, b) (localtime_s(b, a) == 0 ? b : NULL)
#endif
#include <filesystem>
#include <gtest/gtest.h>
#include <locale>
class SatEncoderTest : public testing::TestWithParam<std::string> {};
TEST_F(SatEncoderTest, CheckEqualWhenEqualRandomCircuits) {
std::random_device rd;
std::mt19937 gen(rd());
qc::RandomCliffordCircuit circOne(100, 1, gen());
qc::CircuitOptimizer::flattenOperations(circOne);
std::size_t step1 = 1;
std::size_t j = 1;
std::size_t iList[] = {250, 50};
for (std::size_t k = 0; k < 10; ++k) {
std::size_t i = iList[k];
std::size_t j = 1;
for (; j <= 151; j += step1) {
circOne = qc::RandomCliffordCircuit(i, j, gen());
qc::CircuitOptimizer::flattenOperations(circOne);
auto start = std::chrono::high_resolution_clock::now(); // start timer
auto circTwo = circOne.clone();
SatEncoder satEncoder;
bool result = satEncoder.testEqual(circOne, circTwo);
EXPECT_EQ(result, true);
auto end = std::chrono::high_resolution_clock::now(); // end timer
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count(); // duration in milliseconds
std::ofstream myfile;
myfile.open("dokimiprint1.txt", std::ios::app);
myfile << duration << "ms\n";
myfile.close();
// renaming the original file
std::ostringstream newFileName;
newFileName << "qusat_output_" << i << "_" << j << ".txt";
std::rename("dokimiprint1.txt", newFileName.str().c_str());
}
}
}