Updated TF2_OnIsHolidayActive ret behavior to match doc (
bug 5155, r=fyren).
7 author = "AlliedModders LLC",
8 description = "Basic benchmarks",
10 url = "http://www.sourcemod.net/"
13 #define MATH_INT_LOOPS 2000
14 #define MATH_FLOAT_LOOPS 2000
15 #define STRING_OP_LOOPS 2000
16 #define STRING_FMT_LOOPS 2000
17 #define STRING_ML_LOOPS 2000
18 #define STRING_RPLC_LOOPS 2000
21 new Handle:g_Prof = INVALID_HANDLE
23 public OnPluginStart()
25 RegServerCmd("bench", Benchmark);
26 g_Prof = CreateProfiler();
27 StartProfiling(g_Prof);
28 LoadTranslations("fakedict-sourcemod.cfg");
29 StopProfiling(g_Prof);
30 g_dict_time = GetProfilerTime(g_Prof);
33 public Action:Benchmark(args)
35 PrintToServer("dictionary time: %f seconds", g_dict_time);
38 return Plugin_Handled;
43 StartProfiling(g_Prof);
44 new iter = MATH_INT_LOOPS;
56 a = (a + c) / (b - c);
67 StopProfiling(g_Prof);
68 PrintToServer("int benchmark: %f seconds", GetProfilerTime(g_Prof));
70 StartProfiling(g_Prof);
71 new Float:fa, Float:fb, Float:fc
73 iter = MATH_FLOAT_LOOPS;
78 fc = 6.1 / (float(iter) + 2.5);
82 fc = fb - a + float(3);
84 fa = (fa + fc) / (fb - fc);
87 int1 = RoundToNearest(fa);
88 fb = fa * float(128) - int1;
89 fc = fb * (a + 16.85) * float(RoundToCeil(fb));
94 fa = fc + (float(28)/fa) - RoundToFloor(fc);
96 StopProfiling(g_Prof);
97 PrintToServer("float benchmark: %f seconds", GetProfilerTime(g_Prof));
100 #define KEY1 "LVWANBAGVXSXUGB"
101 #define KEY2 "IDYCVNWEOWNND"
102 #define KEY3 "UZWTRNHY"
103 #define KEY4 "EPRHAFCIUOIG"
104 #define KEY5 "RMZCVWIEY"
109 new i = STRING_FMT_LOOPS;
110 new String:buffer[255];
112 StartProfiling(g_Prof);
117 Format(buffer, sizeof(buffer), "%d", i);
118 Format(buffer, sizeof(buffer), "%d %s %d %f %d %-3.4s %s", i, "gaben", 30, 10.0, 20, "hello", "What a gaben");
119 end = Format(buffer, sizeof(buffer), "Well, that's just %-17.18s!", "what. this isn't a valid string! wait it is");
120 end += Format(buffer[end], sizeof(buffer)-end, "There are %d in this %d", i, end);
121 end += Format(buffer[end], sizeof(buffer)-end, "There are %d in this %d", i, end);
123 StopProfiling(g_Prof);
124 PrintToServer("format() benchmark: %f seconds", GetProfilerTime(g_Prof));
126 StartProfiling(g_Prof);
128 new String:fmtbuf[2048]; /* don't change to decl, amxmodx doesn't use it */
131 Format(fmtbuf, 2047, "%T %T %d %s %f %T", KEY1, LANG_SERVER, KEY2, LANG_SERVER, 50, "what the", 50.0, KEY3, LANG_SERVER);
132 Format(fmtbuf, 2047, "%s %T %s %T %T", "gaben", KEY4, LANG_SERVER, "what TIME is it", KEY5, LANG_SERVER, KEY6, LANG_SERVER);
134 StopProfiling(g_Prof);
135 PrintToServer("ml benchmark: %f seconds", GetProfilerTime(g_Prof));
137 StartProfiling(g_Prof);
143 StopProfiling(g_Prof);
144 PrintToServer("str benchmark: %f seconds", GetProfilerTime(g_Prof));
146 StartProfiling(g_Prof);
147 i = STRING_RPLC_LOOPS;
150 strcopy(fmtbuf, 2047, "This is a test string for you.");
151 ReplaceString(fmtbuf, sizeof(fmtbuf), " ", "ASDF")
152 ReplaceString(fmtbuf, sizeof(fmtbuf), "SDF", "")
153 ReplaceString(fmtbuf, sizeof(fmtbuf), "string", "gnirts")
155 StopProfiling(g_Prof);
156 PrintToServer("replace benchmark: %f seconds", GetProfilerTime(g_Prof));