diff --git a/benchMark.txt b/benchMark.txt new file mode 100644 index 0000000000000000000000000000000000000000..84ffedf75d7e7a95850b7e94781ceabed92c400f --- /dev/null +++ b/benchMark.txt @@ -0,0 +1,53 @@ +Bsplines3 -x*x*x/6 +exp1x (exp(x) - 1)/x +exp1x_log (exp(x) - 1)/log(exp(x)) +intro_example t/(t+1) +logexp log(exp(x)+1) +NMSEexample31 sqrt(x+1) - sqrt(x) +NMSEexample310 log(1 - x)/log(1+x) +NMSEexample34 (1 - cos(x))/sin(x) +NMSEexample35 atan(x+1) - atan(x) +NMSEexample36 1/(sqrt(x)) - 1/sqrt(1+x) +NMSEexample37 exp(x) - 1 +NMSEexample38 (x+1)*log(x+1) - x*log(x) - 1 +NMSEexample39 1/x - 1/tan(x) +NMSEproblem331 1/(x+1) - 1/x +NMSEproblem333 1/(1+x) - 2/x + 1/(x - 1) +NMSEproblem334 pow((x+1),1/3) - pow(x,1/3) +NMSEproblem336 log(x+1) - log(x) +NMSEproblem337 exp(x) - 2+exp(-x) +NMSEproblem341 (1 - cos(x))/(x*x) +NMSEproblem343 log((1 - eps)/(1+eps)) +NMSEproblem344 sqrt((exp(2*x) - 1)/(exp(x) - 1)) +NMSEproblem345 (x - sin(x))/(x - tan(x)) +NMSEsection311 exp(x)/(exp(x) - 1) +predatorPrey (4*x*x)/(1+x/1.11*x/1.11) +sine x - (1.0/6.0)*x*x*x+(1.0/120.0)*x*x*x*x*x - (1.0/5040.0)*x*x*x*x*x*x*x +sineorder3 (238732414637843.0/250000000000000.0)*x - (6450306886639899.0/50000000000000000.0)*x*x*x +sqroot 1.0 + 0.5*x - 0.125*x*x + 0.0625*x*x*x - 0.0390625*x*x*x*x +sqrt_add 1/(sqrt(x + 1) + sqrt(x)) +test05_nonlin1,r4 (x - 1)/(x*x - 1) +test05_nonlin1_test2 1.0/(1+x) +verhulst (4*x)/(1+x/1.11) +ComplexSinCos 1.0/2.0*sin(r)*(exp(-i) - exp(i)) +ComplexSquareRoot 1.0/2.0*sqrt(2.0*(sqrt(x1*x1+x2*x2)+x1)) +doppler1 ((-(1657.0/5.0+3.0/5.0*T))*v)/(((1657.0/5.0+3.0/5.0*T)+u)*((1657.0/5.0+3.0/5.0*T)+u)) +doppler2 ((-(1657/5+3/5*T))*v)/(((1657/5+3/5*T)+u)*((1657/5+3/5*T)+u)) +doppler3 ((-(1657/5+3/5*T))*v)/(((1657/5+3/5*T)+u)*((1657/5+3/5*T)+u)) +hypot32 sqrt(x1*x1+x2*x2) +i4 sqrt(x+y*y) +i6 sin(x*y) +NMSEexample33 sin(x*eps) - sin(x) +NMSEproblem332 tan(x+eps) - tan(x) +NMSEproblem335 cos(x+eps) - cos(x) +NMSEproblem346 pow((x+1),1/n) - pow(x,1/n) +NMSEsection35 exp(a*x) - 1 +polarToCarthesianX radius*cos(3.14159265359/180*theta) +polarToCarthesianY radius*sin(3.14159265359/180*theta) +sec4example ((x1*x2) - 1)/((x1*x2)*(x1*x2) - 1) +test03_nonlin2 (x+y)/(x - y) +theta atan(x2/x1)*180/3.14159265359 +turbine1 (2.0/(r*r)+3.0) - ((3.0 - 2.0*v)*(1.0/8.0)*((w*w)*r*r))/(1.0 - v) - 9.0/2.0 +nonlin1 z/(z+1) +carbonGas 35000000+(401.0/v)*(1000/v)*(v - 0.0427) - 0.0000000000000000041419509 +exp1x_32 (exp(x) - 1)/x \ No newline at end of file diff --git a/benchMarkInterval.txt b/benchMarkInterval.txt new file mode 100644 index 0000000000000000000000000000000000000000..8c85594019d31aa2df29590a05ab80c3fb6d8284 --- /dev/null +++ b/benchMarkInterval.txt @@ -0,0 +1,53 @@ +0 1 +0.01 0.5 +0.01 0.5 +0 999 +-8 8 +0.01 100 +-1 1 +0.01 3 +0.01 100 +0.01 100 +0.01 100 +0.01 100 +0.01 1 +0.01 100 +0.01 0.99 +0.01 100 +0.01 100 +0.01 100 +0.01 100 +-1 1 +0.01 100 +0.01 100 +0.01 100 +0.1 0.3 +-1.57079632679 1.57079632679 +-2 2 +0 1 +1 1000 +1.00001 2 +1.00001 2 +0.1 0.3 +0 1 0 1 +0 1 0 1 +-30 50 -100 100 20 20000 +-40 60 -125 125 15 25000 +-50 30 -30 120 320 20300 +1 100 1 100 +0.1 10 -5 5 +0.1 10 -5 5 +0 100 0 100 +0 100 0 100 +0 100 0 100 +0 1 1 2 +0 1 0 1 +1 10 0 360 +1 10 0 360 +1.001 2 1.001 2 +0 1 -1 -0.1 +1 100 1 100 +3.8 7.8 -4.5 -0.3 0.4 0.9 +0 999 +0.1 0.5 +0.01 0.5 \ No newline at end of file diff --git a/include/benchMark.hpp b/include/benchMark.hpp index 6be7175b52b6546513bfbdda4f8cda008bcef17a..29e6b781c523454b050017148fcb893311813d17 100644 --- a/include/benchMark.hpp +++ b/include/benchMark.hpp @@ -8,6 +8,6 @@ using std::map; using std::string; using std::vector; -map>> initalBenchMark(); +map>> initalBenchMark(); #endif \ No newline at end of file diff --git a/src/benchMark.cpp b/src/benchMark.cpp index 1737199e73875eab5b18de78b849cd9ca08c7184..39abef410a399e89bda8930265c837f03949a474 100644 --- a/src/benchMark.cpp +++ b/src/benchMark.cpp @@ -3,30 +3,54 @@ #include #include #include +#include +#include +#include +#include +using std::cout; +using std::endl; using std::ifstream; using std::map; using std::pair; +using std::stod; using std::string; using std::vector; -map>> initalBenchMark() +map>> initalBenchMark() { - map>> benchMarkData; - ifstream infile; - infile.open("benchMark.txt"); - string buf; - while (getline(infile, buf)) + map>> benchMarkData; + ifstream infile1, infile2; + infile1.open("benchMark.txt"); + infile2.open("benchMarkInterval.txt"); + string buf1, buf2; + while (getline(infile1, buf1) && getline(infile2, buf2)) { - int pos = buf.find(' '); - string name = buf.substr(0, pos); - string expr = buf.substr(pos + 1, buf.length() - pos - 1); - //区间信息暂不确定 - vector interval; - interval.push_back(1024); - map> m1; - m1.insert(pair>(expr, interval)); - benchMarkData.insert(pair>>(name, m1)); + vector intervals; + int pos = buf1.find(' '); + string name = buf1.substr(0, pos); + string expr = buf1.substr(pos + 1, buf1.length() - pos - 1); + char s[1024]; + for (size_t i = 0; i < buf2.size(); i++) + { + s[i] = buf2[i]; + } + vector res; + string str = buf2; + std::stringstream input(str); + string temp; + const char pattern = ' '; + while (getline(input, temp, pattern)) + { + res.push_back(temp); + } + for (size_t k = 0; k < res.size(); k++) + { + intervals.push_back(atof(res.at(k).c_str())); + } + map> m1; + m1.insert(pair>(expr, intervals)); + benchMarkData.insert(pair>>(name, m1)); } return benchMarkData; diff --git a/src/main.cpp b/src/main.cpp index aebfcb114b667cd4916ec4bf98da3117db06c126..7433da569dba38c69d7d5bd77c2f89f763dbbb60 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,10 +76,14 @@ int main() auto benchMarkData = initalBenchMark(); auto pos = benchMarkData.find(inputStr); + bool isBenchMark = false; + string name; if (pos != benchMarkData.end()) { + name = inputStr; inputStr = pos->second.begin()->first; cout << inputStr << endl; + isBenchMark = true; } const char *split = " "; @@ -94,15 +98,22 @@ int main() // after input completed, start timing auto timeStart = std::chrono::high_resolution_clock::now(); - - string intervalStr; - getline(cin, intervalStr); - auto intervals = getIntervals(intervalStr, split); + vector intervals; + if (isBenchMark) + { + intervals = pos->second.begin()->second; + } + else + { + string intervalStr; + getline(cin, intervalStr); + intervals = getIntervals(intervalStr, split); + } // For temporary use only . It will be replaced by geneBoundaryData and geneIntervalData ofstream ofs; ofs.open("intervalData.txt", ios::out); - for (int i = 0; i < intervals.size(); i++) + for (size_t i = 0; i < intervals.size(); i++) { if (i == intervals.size() - 1) { @@ -120,7 +131,7 @@ int main() // string scaleStr; // getline(cin, scaleStr); // vector scales = getScales(scaleStr, split); - + // Default scale setting according to the variables' size int sampleScale; if (vars.size() == 1) @@ -140,7 +151,7 @@ int main() sampleScale = 10; } vector scales; - for (int i = 0; i < vars.size(); i++) + for (size_t i = 0; i < vars.size(); i++) { scales.push_back(sampleScale); } @@ -149,6 +160,10 @@ int main() if (runAllFlag) { // the whole process auto uniqueLabel = getUniqueLabel(); + if (isBenchMark) + { + uniqueLabel = name; + } cout << "uniqueLabel: " << uniqueLabel << endl; auto funcNameOrigin = geneOriginCodeKernel(inputStr, vars, uniqueLabel, "origin");