This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- (c) Dmitry Sharonov если что - я вчера на скорую руку добавил в семлпер еще тройку лидеров из топа, вот так: | |
local top = fun.iter(fiber.top().cpu):map(function(name, f) f.name=name; return f end):totable() | |
table.sort(top, function(f1, f2) return f1.average > f2.average end) | |
log.info(require('yaml').encode(fun.iter(top):take(3):totable())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use 5.010; | |
use strict; | |
use File::Find; | |
use Getopt::Long; | |
sub usage { | |
return <<EOF | |
=============================================================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ffi = require 'ffi' | |
if not pcall(ffi.typeof, 'struct tm') then | |
ffi.cdef[[ | |
struct tm { | |
int tm_sec; | |
int tm_min; | |
int tm_hour; | |
int tm_mday; | |
int tm_mon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if not pcall(assert, false, {}) then | |
local a = _G.assert | |
assert = function(t, m) | |
if t == nil then | |
error("value expected", 2) | |
end | |
if not t then | |
if m == nil then | |
error("assertion failed", 2) | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> tarantool -l fiber -l clock -e 'fiber.create(function() while true do while clock.time() < fiber.time()+0.1 do end fiber.sleep(0.01) end end)' test.lua | |
entering the event loop | |
e:100.011µs p:0.017µs t:99.998µs | |
e:100.042µs p:0.010µs t:100.035µs | |
e:100.013µs p:0.015µs t:100.004µs | |
e:100.005µs p:0.006µs t:99.994µs | |
e:100.007µs p:0.004µs t:99.996µs | |
e:100.010µs p:0.009µs t:99.993µs | |
e:100.012µs p:0.016µs t:100.000µs | |
e:100.009µs p:0.050µs t:99.999µs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local TOO_LONG_CALL_THRESHOLD = 0.1 | |
local log = require('log') | |
local clock = require 'clock' | |
local json = require 'json'.new() json.cfg{ encode_use_tostring = true } | |
local function ftail(fname, args, start, ...) | |
local run = clock.realtime() - start | |
if run > TOO_LONG_CALL_THRESHOLD then | |
log.info("Function call %s(%s) was too long: %0.2fs", fname, json.encode(args), run) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local client = require 'http.client' | |
local fiber = require 'fiber' | |
local yaml = require 'yaml' | |
local uris = { | |
'http://httpbin.org/get?1', | |
'http://httpbin.org/get?2', | |
'http://httpbin.org/get?3', | |
'http://httpbin.org/get?4', | |
'http://httpbin.org/get?5', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local fiber = require 'fiber' | |
local clock = require 'clock' | |
local N = 1e6 | |
do | |
local i = 0; | |
local cond = fiber.cond() | |
local function creator() | |
i = i + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tarantool quick test | |
// Copyright, Dennis Anikin 2016 | |
// | |
// Quick disclaimer: | |
// | |
// This test shows 500K-1000K transactions per second on one CPU core | |
// and 600K-1600K queries per second on one CPU core. | |
// | |
// Based on the $6.57 per-month-price for the AWS t2.micro instance we can afford the tremendous number of 630bln queries for just $1 | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _,expr in pairs({ | |
"1", | |
"N", | |
"N/2+1", | |
"N/2+2", | |
"math.random()" | |
}) do | |
local fun,err = loadstring("return "..expr) | |
if not fun then error("Bad expression '"..expr.."'") end | |
local count = math.floor(math.random(7)) |
NewerOlder