CoolProp  6.6.0
An open-source fluid property and humid air property database
SpeedTest.cpp
Go to the documentation of this file.
1 #include <memory>
2 #include "SpeedTest.h"
3 #include "AbstractState.h"
4 #include "DataStructures.h"
6 
7 #include <time.h>
8 
9 // A hack to make powerpc happy since sysClkRateGet not found
10 #if defined(__powerpc__)
11 # define CLOCKS_PER_SEC 1000
12 #endif
13 
14 namespace CoolProp {
15 
16 void compare_REFPROP_and_CoolProp(const std::string& fluid, CoolProp::input_pairs inputs, double val1, double val2, std::size_t N, double d1,
17  double d2) {
18  time_t t1, t2;
19 
20  shared_ptr<AbstractState> State(AbstractState::factory("HEOS", fluid));
21  t1 = clock();
22  for (std::size_t ii = 0; ii < N; ++ii) {
23  State->update(inputs, val1 + ii * d1, val2 + ii * d2);
24  }
25  t2 = clock();
26 
27  double elap = ((double)(t2 - t1)) / CLOCKS_PER_SEC / ((double)N) * 1e6;
28  std::cout << format("Elapsed time for CoolProp is %g us/call\n", elap);
29 
30  State.reset(AbstractState::factory("REFPROP", fluid));
31  t1 = clock();
32  for (std::size_t ii = 0; ii < N; ++ii) {
33  State->update(inputs, val1 + ii * d1, val2 + ii * d2);
34  }
35  t2 = clock();
36  elap = ((double)(t2 - t1)) / CLOCKS_PER_SEC / ((double)N) * 1e6;
37  std::cout << format("Elapsed time for REFPROP is %g us/call\n", elap);
38 }
39 
40 } /* namespace CoolProp */