Advertisement
Guest User

dd

a guest
Jun 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.20 KB | None | 0 0
  1. function Function( Table )
  2.     local Canceled = {}
  3.     return coroutine.wrap(
  4.     function()
  5.         for Key, Value in pairs( Table ) do
  6.             coroutine.yield( false, false, Table, Key, Value )
  7.             if ( type( Value ) == "table" and next( Value ) and not Canceled[Value] ) then
  8.                 local _Table = { { Table, Key, Value, pairs( Value ), nil } }
  9.                 repeat
  10.                     local Maxn = table.maxn( _Table ) local Key, Value = _Table[Maxn][4]( _Table[Maxn][3], _Table[Maxn][5] )
  11.                     if ( not Canceled[_Table[Maxn][3]] and not Canceled[_Table[Maxn][1]] and Key and Value ) then
  12.                         _Table[Maxn][5] = Key
  13.                         coroutine.yield( _Table[Maxn][1], _Table[Maxn][2], _Table[Maxn][3], Key, Value )
  14.                         if ( type( Value ) == "table" ) then _Table[Maxn + 1] = { _Table[Maxn][3], Key, Value, pairs( Value ), nil } end
  15.                     else
  16.                         _Table[Maxn] = nil
  17.                     end
  18.                 until ( table.getn( _Table ) == 0 )
  19.             end
  20.         end
  21.     end ), function( Table ) local _type = type( Table ) if ( _type == "table" ) then Canceled[Table] = true return true else error( "attempt to cancel (a ".._type.." value) from looping" ) end end
  22. end
  23.  
  24. local Categories = {
  25.     "Lua timing",               "Lua memory",           "Lib memory",               "Packet usage",
  26.     "RPC Packet usage",         "Event Packet usage",   "Player packet usage",      "Sqlite timing",
  27.     "Bandwidth reduction",      "Bandwidth usage",      "Server info",              "Server timing",
  28.     "Function stats",           "Debug info",           "Debug table",              "Help"
  29. }
  30.  
  31. if ( fileExists( "Results.txt" ) ) then fileDelete( "Results.txt" ) end
  32. local File, Column, Rows = fileCreate( "Results.txt" )
  33.  
  34. for Category = 1, 16 do
  35.     Category = Categories[Category]
  36.     fileWrite( File, "\n"..Category..":" )
  37.     Columns, Rows = getPerformanceStats( Category )
  38.     for _, _, _, Key, Value in Function( Columns ) do
  39.         fileWrite( File, "\n\tColumns: \""..tostring( Key ).."\" = \""..tostring( Value ).."\"" )
  40.     end
  41.     for _, _, _, Key, Value in Function( Rows ) do
  42.         fileWrite( File, "\n\tRows: \""..tostring( Key ).."\" = \""..tostring( Value ).."\"" )
  43.     end
  44. end
  45.  
  46. fileClose( File )
  47. outputChatBox( "Done!" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement