Created
February 15, 2012 03:22
-
-
Save Deco/1832914 to your computer and use it in GitHub Desktop.
HL2:SB benchmark example
This file contains 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
--======== Copyleft © 2010-2011, Team Sandbox, Some rights reserved. ========-- | |
-- | |
-- Purpose: Tests the speed of FStrEq vs "".__eq. | |
-- | |
--===========================================================================-- | |
local Count = 10000 | |
local Time = engine.Time | |
local flTimeExecution | |
local print = print | |
local FStrEq = FStrEq | |
local flTimeFStrEq | |
local flTime__eq | |
local Warning = dbg.Warning | |
local strChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~" | |
local srahCtrs = "~._-9876543210ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba" | |
local FStrEq_ret = 0 | |
flTimeExecution = Time() | |
for i = 1, Count do | |
FStrEq_ret = FStrEq_ret+( FStrEq( strChars, srahCtrs ) and 1 or 0 ) | |
end | |
flTimeExecution = Time() - flTimeExecution | |
flTimeFStrEq = flTimeExecution | |
local __eq_ret = 0 | |
flTimeExecution = Time() | |
for i = 1, Count do | |
__eq_ret = __eq_ret + ( strChars == srahCtrs and 1 or 0 ) | |
end | |
flTimeExecution = Time() - flTimeExecution | |
flTime__eq = flTimeExecution | |
if ( flTimeFStrEq < flTime__eq ) then | |
Warning( "FStrEq beat \"\".__eq by " .. flTime__eq - flTimeFStrEq .. " seconds!\n", FStrEq_ret, __eq_ret ) | |
elseif ( flTime__eq < flTimeFStrEq ) then | |
Warning( "\"\".__eq beat FStrEq by " .. flTimeFStrEq - flTime__eq .. " seconds!\n", __eq_ret, FStrEq_ret ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment