diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-07-26 10:49:23 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-07-26 10:49:23 +0100 |
commit | 537a7180a0d5132c11636c4fd8b1450cd99d352c (patch) | |
tree | fb9f8c84955a411bdffbd6371ea32f2716fb3687 /test/rspamd_lua_pcall_vs_resume_test.c | |
parent | 5fd7a90fdaa33f52c59bdb0ca84451e5c1e22365 (diff) | |
download | rspamd-537a7180a0d5132c11636c4fd8b1450cd99d352c.tar.gz rspamd-537a7180a0d5132c11636c4fd8b1450cd99d352c.zip |
[Rework] Use clang-format to unify formatting in all sources
No meaningful changes.
Diffstat (limited to 'test/rspamd_lua_pcall_vs_resume_test.c')
-rw-r--r-- | test/rspamd_lua_pcall_vs_resume_test.c | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/test/rspamd_lua_pcall_vs_resume_test.c b/test/rspamd_lua_pcall_vs_resume_test.c index c06283de1..0502378c9 100644 --- a/test/rspamd_lua_pcall_vs_resume_test.c +++ b/test/rspamd_lua_pcall_vs_resume_test.c @@ -32,15 +32,15 @@ test_pcall(lua_State *L, gint function_call) { gdouble t1, t2; gint i; - t1 = rspamd_get_virtual_ticks (); + t1 = rspamd_get_virtual_ticks(); - for (i = 0; i < N; i ++) { - lua_rawgeti (L, LUA_REGISTRYINDEX, function_call); - lua_pcall (L, 0, 1, 0); - lua_pop (L, 1); + for (i = 0; i < N; i++) { + lua_rawgeti(L, LUA_REGISTRYINDEX, function_call); + lua_pcall(L, 0, 1, 0); + lua_pop(L, 1); } - t2 = rspamd_get_virtual_ticks (); + t2 = rspamd_get_virtual_ticks(); return t2 - t1; } @@ -50,21 +50,21 @@ test_resume(lua_State *L, gint function_call) { gdouble t1, t2; gint i; - t1 = rspamd_get_virtual_ticks (); + t1 = rspamd_get_virtual_ticks(); - for (i = 0; i < N; i ++) { - lua_rawgeti (L, LUA_REGISTRYINDEX, function_call); + for (i = 0; i < N; i++) { + lua_rawgeti(L, LUA_REGISTRYINDEX, function_call); #if LUA_VERSION_NUM < 502 - lua_resume (L, 0); + lua_resume(L, 0); #elif LUA_VERSION_NUM >= 504 - lua_resume (L, NULL, 0, NULL); + lua_resume(L, NULL, 0, NULL); #else - lua_resume (L, NULL, 0); + lua_resume(L, NULL, 0); #endif - lua_pop (L, 1); + lua_pop(L, 1); } - t2 = rspamd_get_virtual_ticks (); + t2 = rspamd_get_virtual_ticks(); return t2 - t1; } @@ -76,25 +76,25 @@ test_resume_get_thread(gint function_call) gint i; struct thread_entry *ent; - t1 = rspamd_get_virtual_ticks (); + t1 = rspamd_get_virtual_ticks(); - for (i = 0; i < N; i ++) { - ent = lua_thread_pool_get_for_config (rspamd_main->cfg); + for (i = 0; i < N; i++) { + ent = lua_thread_pool_get_for_config(rspamd_main->cfg); - lua_rawgeti (ent->lua_state, LUA_REGISTRYINDEX, function_call); + lua_rawgeti(ent->lua_state, LUA_REGISTRYINDEX, function_call); #if LUA_VERSION_NUM < 502 - lua_resume (ent->lua_state, 0); + lua_resume(ent->lua_state, 0); #elif LUA_VERSION_NUM >= 504 - lua_resume (ent->lua_state, NULL, 0, NULL); + lua_resume(ent->lua_state, NULL, 0, NULL); #else - lua_resume (ent->lua_state, NULL, 0); + lua_resume(ent->lua_state, NULL, 0); #endif - lua_pop (ent->lua_state, 1); + lua_pop(ent->lua_state, 1); - lua_thread_pool_return (rspamd_main->cfg->lua_thread_pool, ent); + lua_thread_pool_return(rspamd_main->cfg->lua_thread_pool, ent); } - t2 = rspamd_get_virtual_ticks (); + t2 = rspamd_get_virtual_ticks(); return t2 - t1; } @@ -106,56 +106,55 @@ test_resume_get_new_thread(gint function_call) gint i; struct thread_entry *ent; - t1 = rspamd_get_virtual_ticks (); + t1 = rspamd_get_virtual_ticks(); - for (i = 0; i < N; i ++) { - ent = lua_thread_pool_get_for_task (rspamd_main->cfg->lua_thread_pool); + for (i = 0; i < N; i++) { + ent = lua_thread_pool_get_for_task(rspamd_main->cfg->lua_thread_pool); - lua_rawgeti (ent->lua_state, LUA_REGISTRYINDEX, function_call); + lua_rawgeti(ent->lua_state, LUA_REGISTRYINDEX, function_call); #if LUA_VERSION_NUM < 502 - lua_resume (ent->lua_state, 0); + lua_resume(ent->lua_state, 0); #elif LUA_VERSION_NUM >= 504 - lua_resume (ent->lua_state, NULL, 0, NULL); + lua_resume(ent->lua_state, NULL, 0, NULL); #else - lua_resume (ent->lua_state, NULL, 0); + lua_resume(ent->lua_state, NULL, 0); #endif - lua_pop (ent->lua_state, 1); + lua_pop(ent->lua_state, 1); /* lua_thread_pool_return (rspamd_main->cfg->lua_thread_pool, ent); */ } - t2 = rspamd_get_virtual_ticks (); + t2 = rspamd_get_virtual_ticks(); return t2 - t1; } -void -rspamd_lua_lua_pcall_vs_resume_test_func (void) +void rspamd_lua_lua_pcall_vs_resume_test_func(void) { lua_State *L = rspamd_main->cfg->lua_state; gchar *lua_src; gdouble t1, reference; - lua_src = g_build_filename (argv0_dirname, lua_src_name, NULL); - if (luaL_dofile (L, lua_src) != 0) { - msg_err ("failed to load test file: %s ", lua_tostring (L, -1)); - g_assert (0); + lua_src = g_build_filename(argv0_dirname, lua_src_name, NULL); + if (luaL_dofile(L, lua_src) != 0) { + msg_err("failed to load test file: %s ", lua_tostring(L, -1)); + g_assert(0); } - g_free (lua_src); + g_free(lua_src); - gint function_call = luaL_ref (L, LUA_REGISTRYINDEX); + gint function_call = luaL_ref(L, LUA_REGISTRYINDEX); - msg_info ("calling"); + msg_info("calling"); reference = t1 = test_pcall(L, function_call); - msg_notice ("pcall stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1/(gdouble)N, t1 / reference); + msg_notice("pcall stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (gdouble) N, t1 / reference); - t1 = test_resume (L, function_call); - msg_notice ("resume stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1/(gdouble)N, t1 / reference); + t1 = test_resume(L, function_call); + msg_notice("resume stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (gdouble) N, t1 / reference); - t1 = test_resume_get_thread (function_call); - msg_notice ("resume+get thread stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1/(gdouble)N, t1 / reference); + t1 = test_resume_get_thread(function_call); + msg_notice("resume+get thread stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (gdouble) N, t1 / reference); - t1 = test_resume_get_new_thread (function_call); - msg_notice ("resume+get [new] thread stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1/(gdouble)N, t1 / reference); + t1 = test_resume_get_new_thread(function_call); + msg_notice("resume+get [new] thread stat: ts: %1.5f, avg:%1.5f, slow=%1.2f", t1, t1 / (gdouble) N, t1 / reference); } |