Merge branch 'develop' of github.com:ChaiScript/ChaiScript into develop
This commit is contained in:
commit
fd2539145a
@ -249,6 +249,13 @@ void interactive(chaiscript::ChaiScript& chai)
|
||||
}
|
||||
}
|
||||
|
||||
double now()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
auto now = high_resolution_clock::now();
|
||||
return duration_cast<duration<double>>(now.time_since_epoch()).count();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
@ -288,6 +295,8 @@ int main(int argc, char *argv[])
|
||||
chai.add(chaiscript::fun(&help), "help");
|
||||
chai.add(chaiscript::fun(&throws_exception), "throws_exception");
|
||||
chai.add(chaiscript::fun(&get_eval_error), "get_eval_error");
|
||||
chai.add(chaiscript::fun(&now), "now");
|
||||
|
||||
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
if ( i == 0 && argc > 1 ) {
|
||||
|
13
unittests/performance.chai
Normal file
13
unittests/performance.chai
Normal file
@ -0,0 +1,13 @@
|
||||
var sum = 0.0
|
||||
var start = now()
|
||||
for (var i = 1; i <= 100000; ++i) {
|
||||
if (i % 2 == 0) {
|
||||
sum += 1.0 / i;
|
||||
}
|
||||
else {
|
||||
sum += 1.0 / (double(i) * i);
|
||||
}
|
||||
}
|
||||
var end = now()
|
||||
print("Elapsed time: " + to_string(end - start) + " sum: " + to_string(sum))
|
||||
assert_equal(to_string(sum), "6.9322")
|
Loading…
x
Reference in New Issue
Block a user