Skip to content

Commit b818799

Browse files
committed
Added getTimeInSeconds() helper to chai executable
1 parent fdcc595 commit b818799

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ void interactive(chaiscript::ChaiScript& chai)
249249
}
250250
}
251251

252+
double getTimeInSeconds()
253+
{
254+
using namespace std::chrono;
255+
static time_point<high_resolution_clock> start = high_resolution_clock::now();
256+
257+
duration<double> elapsed_seconds = high_resolution_clock::now() - start;
258+
return elapsed_seconds.count();
259+
}
260+
252261
int main(int argc, char *argv[])
253262
{
254263

@@ -288,6 +297,8 @@ int main(int argc, char *argv[])
288297
chai.add(chaiscript::fun(&help), "help");
289298
chai.add(chaiscript::fun(&throws_exception), "throws_exception");
290299
chai.add(chaiscript::fun(&get_eval_error), "get_eval_error");
300+
chai.add(chaiscript::fun(&getTimeInSeconds), "getTimeInSeconds");
301+
291302

292303
for (int i = 0; i < argc; ++i) {
293304
if ( i == 0 && argc > 1 ) {

0 commit comments

Comments
 (0)