Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <SFML/System.hpp>
- extern "C"
- {
- #include "lua.h"
- #include "lauxlib.h"
- #include "lualib.h"
- }
- using namespace std;
- using namespace luabridge;
- using namespace sf;
- int main()
- {
- string luaF = "test.lua";
- lua_State *L;
- L = luaL_newstate();
- luaL_openlibs( L );
- int e = luaL_loadfile( L, luaF.c_str() );
- unsigned int maxTime = 0;
- lua_pcall( L, 0, 0, 0 );
- //lua_gc( L, LUA_GCSTOP, 0 );
- for( int j = 0; j < 15; ++j )
- {
- maxTime = 0;
- sf::Int64 totalTime = 0;
- double avgTime = 0;
- sf::Int64 iterations = 1000;
- sf::Clock clock1;
- for( int i = 0; i < iterations; ++i )
- {
- clock1.restart();
- lua_getglobal( L, "blah" );
- lua_pcall( L, 0, 0 , 0);
- sf::Int64 time = clock1.getElapsedTime().asMicroseconds();
- if( time > maxTime ) maxTime = time;
- totalTime += time;
- }
- avgTime = totalTime / (double)iterations;
- cout << "maxTime: " << maxTime << endl;
- cout << "avgTime: " << avgTime << endl;
- cout << endl;
- }
- cin >> maxTime;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement