summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/luajit-3065c9/src/jit/zone.lua
diff options
context:
space:
mode:
Diffstat (limited to 'fluent-bit/lib/luajit-3065c9/src/jit/zone.lua')
-rw-r--r--fluent-bit/lib/luajit-3065c9/src/jit/zone.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/fluent-bit/lib/luajit-3065c9/src/jit/zone.lua b/fluent-bit/lib/luajit-3065c9/src/jit/zone.lua
new file mode 100644
index 00000000..1308cb74
--- /dev/null
+++ b/fluent-bit/lib/luajit-3065c9/src/jit/zone.lua
@@ -0,0 +1,45 @@
+----------------------------------------------------------------------------
+-- LuaJIT profiler zones.
+--
+-- Copyright (C) 2005-2022 Mike Pall. All rights reserved.
+-- Released under the MIT license. See Copyright Notice in luajit.h
+----------------------------------------------------------------------------
+--
+-- This module implements a simple hierarchical zone model.
+--
+-- Example usage:
+--
+-- local zone = require("jit.zone")
+-- zone("AI")
+-- ...
+-- zone("A*")
+-- ...
+-- print(zone:get()) --> "A*"
+-- ...
+-- zone()
+-- ...
+-- print(zone:get()) --> "AI"
+-- ...
+-- zone()
+--
+----------------------------------------------------------------------------
+
+local remove = table.remove
+
+return setmetatable({
+ flush = function(t)
+ for i=#t,1,-1 do t[i] = nil end
+ end,
+ get = function(t)
+ return t[#t]
+ end
+}, {
+ __call = function(t, zone)
+ if zone then
+ t[#t+1] = zone
+ else
+ return (assert(remove(t), "empty zone stack"))
+ end
+ end
+})
+