diff --git a/src/sb_lua.c b/src/sb_lua.c index 72a4793..b7d75d1 100644 --- a/src/sb_lua.c +++ b/src/sb_lua.c @@ -885,12 +885,14 @@ int sb_lua_db_connect(lua_State *L) sb_lua_ctxt_t * const ctxt = &tls_lua_ctxt; ctxt->driver = db_create(NULL); - if (ctxt->driver == NULL) { + if (ctxt->driver == NULL) + { luaL_error(L, "DB initialization failed"); - lua_pushstring(L, ctxt->driver->sname); - lua_setglobal(L, "db_driver"); } + lua_pushstring(L, ctxt->driver->sname); + lua_setglobal(L, "db_driver"); + if (ctxt->con != NULL) return 0; diff --git a/src/tests/cpu/sb_cpu.c b/src/tests/cpu/sb_cpu.c index f3dfed6..46a9cf9 100644 --- a/src/tests/cpu/sb_cpu.c +++ b/src/tests/cpu/sb_cpu.c @@ -27,6 +27,8 @@ # include #endif +#include + #include "sysbench.h" /* CPU test arguments */ @@ -42,6 +44,7 @@ static int cpu_init(void); static void cpu_print_mode(void); static sb_event_t cpu_next_event(int thread_id); static int cpu_execute_event(sb_event_t *, int); +static void cpu_report_cumulative(sb_stat_t *); static int cpu_done(void); static sb_test_t cpu_test = @@ -53,6 +56,7 @@ static sb_test_t cpu_test = .print_mode = cpu_print_mode, .next_event = cpu_next_event, .execute_event = cpu_execute_event, + .report_cumulative = cpu_report_cumulative, .done = cpu_done }, .args = cpu_args @@ -124,6 +128,18 @@ void cpu_print_mode(void) log_text(LOG_NOTICE, "Prime numbers limit: %d\n", max_prime); } +/* Print cumulative stats. */ + +void cpu_report_cumulative(sb_stat_t *stat) +{ + log_text(LOG_NOTICE, "CPU speed:"); + log_text(LOG_NOTICE, " events per second: %8.2f", + stat->events / stat->time_interval); + + sb_report_cumulative(stat); +} + + int cpu_done(void) { return 0; diff --git a/tests/t/test_cpu.t b/tests/t/test_cpu.t index 645b205..61eb725 100644 --- a/tests/t/test_cpu.t +++ b/tests/t/test_cpu.t @@ -27,6 +27,8 @@ cpu benchmark tests Threads started! + CPU speed: + events per second: *.* (glob) General statistics: total time: *s (glob)