Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2013
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <SFML/System.hpp>
  4.  
  5. extern "C"
  6. {
  7. #include "lua.h"
  8. #include "lauxlib.h"
  9. #include "lualib.h"
  10. }
  11.  
  12. using namespace std;
  13. using namespace luabridge;
  14. using namespace sf;
  15.  
  16. int main()
  17. {
  18.     string luaF = "test.lua";
  19.     lua_State *L;
  20.     L = luaL_newstate();
  21.     luaL_openlibs( L );
  22.  
  23.     int e = luaL_loadfile( L, luaF.c_str() );
  24.  
  25.     unsigned int maxTime = 0;
  26.  
  27.     lua_pcall( L, 0, 0, 0 );
  28.  
  29.     //lua_gc( L, LUA_GCSTOP, 0 );
  30.  
  31.     for( int j = 0; j < 15; ++j )
  32.     {
  33.         maxTime = 0;
  34.         sf::Int64 totalTime = 0;
  35.         double avgTime = 0;
  36.         sf::Int64 iterations = 1000;
  37.         sf::Clock clock1;
  38.         for( int i = 0; i < iterations; ++i )
  39.         {          
  40.             clock1.restart();
  41.  
  42.             lua_getglobal( L, "blah" );
  43.             lua_pcall( L, 0, 0 , 0);
  44.  
  45.             sf::Int64 time = clock1.getElapsedTime().asMicroseconds();
  46.             if( time > maxTime ) maxTime = time;
  47.             totalTime += time;
  48.         }
  49.         avgTime = totalTime / (double)iterations;
  50.  
  51.         cout << "maxTime: " << maxTime << endl;
  52.         cout << "avgTime: " << avgTime << endl;
  53.         cout << endl;
  54.     }
  55.     cin >> maxTime;
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement