From 467e338ade177a3b1570b6d79b8cd4aff7d5c07f Mon Sep 17 00:00:00 2001 From: Alexandr <a.lyapunov@corp.mail.ru> Date: Thu, 7 Aug 2014 16:06:32 +0400 Subject: [PATCH] fix gh-213 --- src/box/lua/slab.cc | 18 ++++++++++++++++++ test/box/misc.result | 6 ++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/box/lua/slab.cc b/src/box/lua/slab.cc index 0a88bd0c9c..6b0fe31929 100644 --- a/src/box/lua/slab.cc +++ b/src/box/lua/slab.cc @@ -97,6 +97,24 @@ lbox_slab_info(struct lua_State *L) lua_pushstring(L, "arena_size"); luaL_pushnumber64(L, totals.total); lua_settable(L, -3); + + char value[32]; + double items_used_perc = 100 + * ((double)totals.used) + / ((double)talloc.cache->arena->prealloc + 0.0001); + snprintf(value, sizeof(value), "%0.1lf%%", items_used_perc); + lua_pushstring(L, "items_used_%"); + lua_pushstring(L, value); + lua_settable(L, -3); + + double arena_used_perc = 100 + * ((double)talloc.cache->arena->used) + / ((double)talloc.cache->arena->prealloc + 0.0001); + snprintf(value, sizeof(value), "%0.1lf%%", arena_used_perc); + lua_pushstring(L, "arena_used_%"); + lua_pushstring(L, value); + lua_settable(L, -3); + return 1; } diff --git a/test/box/misc.result b/test/box/misc.result index f144c5debf..16611f5ec8 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -147,9 +147,11 @@ end; ... t; --- -- - slabs - - arena_size +- - arena_used_% - arena_used + - items_used_% + - arena_size + - slabs ... ---------------- -- # box.error -- GitLab