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 strict; | |
use 5.010; | |
use AnyEvent; | |
use AnyEvent::HTTP; | |
use Time::HiRes 'time'; | |
my $records = [ (1)x4e3 ]; | |
my $i = 0; |
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 strict; | |
use 5.010; | |
use AnyEvent; | |
use Time::HiRes 'time'; | |
sub async (&) { | |
my $code = shift; | |
my $t;$t = AE::timer 0,0,sub { undef $t;$code->(); } |
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 EV; | |
use Scalar::Util 'weaken'; | |
my @tasks = qw(1 2 3); | |
sub dbg(@) { | |
printf "[%0.06f] %s\n",EV::now(), "@_"; | |
} |
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
// "License": Public Domain | |
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like. | |
#ifndef PORTABLE_ENDIAN_H__ | |
#define PORTABLE_ENDIAN_H__ | |
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__) | |
# define __WINDOWS__ |
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
use 5.010; | |
use CBOR::XS; | |
use Data::Dumper; | |
my $cbor = CBOR::XS->new(); | |
my $data = "\x82\x01\xD9\x56\x52\x44test"; | |
say Dumper $cbor->decode($data); | |
my $buf; | |
for (split //, $data) { | |
$buf .= $_; |
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 box.sandbox then | |
box.sandbox = nil | |
end | |
local ffi = require 'ffi' | |
ffi.cdef [[ | |
void exit(int) | |
]] | |
box.fiber.wrap(function() |
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 r,e = pcall(function () | |
local res = peer:call('box.raise', tostring(box.error.ER_PROC_LUA), "Test die" ) | |
end) | |
print("call res = ",r," ",e) | |
local r,e = xpcall(function () | |
local res = peer:call('box.raise', tostring(box.error.ER_PROC_LUA), "Test die" ) | |
end, function(...) | |
print("Error: ",...) |
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 iproto_proto = Proto("iproto", "iproto protocol") | |
function iproto_proto.dissector(buffer, pinfo, tree) | |
pinfo.cols.protocol = "IPROTO" | |
local iprotree = tree:add(iproto_proto, buffer(), "IPROTO") | |
local buffer_len = buffer:len() | |
local offset = 0 | |
while offset < buffer_len do | |
local len = buffer((offset + 4), 4):le_uint() | |
local sync = buffer((offset+8), 4):le_uint() |
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
se uni::perl; | |
use Benchmark ':all'; | |
use lib::abs; | |
BEGIN {unshift @INC, lib::abs::path 'kraih/lib' } | |
use Mojo::ByteStream 'b';; | |
say $INC{'Mojo/ByteStream.pm'}; | |
my %results; | |
$results{old} = timethis -1 , sub { b('x'x1000) }; |
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
use uni::perl; | |
use Benchmark ':all'; | |
use lib::abs; | |
BEGIN {unshift @INC, lib::abs::path 'kraih/lib' } | |
use Mojo::ByteStream 'b';; | |
say $INC{'Mojo/ByteStream.pm'}; | |
my %results; | |
$results{old1} = timethis -1 , sub { b("тестовая строка")->encode('utf8')->decode('utf8') }; |
OlderNewer