Created
October 19, 2016 20:40
-
-
Save hikilaka/c49dd5a3d102c42cd2813859f17a354a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto exec_chaiscript() { | |
auto opts = { | |
chaiscript::Options::No_Load_Modules, | |
chaiscript::Options::External_Scripts | |
}; | |
chaiscript::ChaiScript engine({}, {}, opts); | |
engine.use("prime.chai"); | |
auto start = std::chrono::high_resolution_clock::now(); | |
int primes = engine.eval<int>("primes(10000)"); | |
auto end = std::chrono::high_resolution_clock::now(); | |
return std::make_tuple(primes, end - start); | |
} | |
auto exec_lua() { | |
auto engine = luaL_newstate(); | |
luaL_dofile(engine, "prime.lua"); | |
auto start = std::chrono::high_resolution_clock::now(); | |
lua_getglobal(engine, "primes"); | |
lua_pushnumber(engine, 10000); | |
lua_call(engine, 1, 1); | |
int primes = (int) lua_tointeger(engine, -1); | |
lua_pop(engine, 1); | |
auto end = std::chrono::high_resolution_clock::now(); | |
lua_close(engine); | |
return std::make_tuple(primes, end - start); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment