The long array time was:
BERT v3 long array               0.520000   0.000000   0.520000 (  0.522735)

and now it is:
BERT v3 long array               0.190000   0.000000   0.190000 (  0.183106)

The full benchmark output:
                                     user     system      total        real
BERT v1 tiny                     0.010000   0.000000   0.010000 (  0.013550)
BERT v1 small                    0.120000   0.020000   0.140000 (  0.124408)
BERT v1 large                    0.520000   0.000000   0.520000 (  0.534007)
BERT v1 complex                  2.730000   0.010000   2.740000 (  2.758483)
BERT v1 long array               5.150000   0.030000   5.180000 (  5.202551)
BERT v2 tiny                     0.020000   0.000000   0.020000 (  0.019604)
BERT v2 small                    0.120000   0.000000   0.120000 (  0.121305)
BERT v2 large                    0.630000   0.000000   0.630000 (  0.630657)
BERT v2 complex                  2.590000   0.000000   2.590000 (  2.586704)
BERT v2 long array               5.390000   0.020000   5.410000 (  5.453956)
BERT v3 tiny                     0.000000   0.000000   0.000000 (  0.005028)
BERT v3 small                    0.000000   0.010000   0.010000 (  0.006714)
BERT v3 large                    0.220000   0.040000   0.260000 (  0.259619)
BERT v3 complex                  0.040000   0.000000   0.040000 (  0.040061)
BERT v3 long array               0.190000   0.000000   0.190000 (  0.183106)
JSON tiny                        0.000000   0.000000   0.000000 (  0.008714)
JSON small                       0.020000   0.000000   0.020000 (  0.013369)
JSON large                       2.280000   0.010000   2.290000 (  2.332599)
JSON complex                     0.150000   0.000000   0.150000 (  0.145547)
JSON long array                  0.530000   0.000000   0.530000 (  0.526635)
YAJL tiny                        0.000000   0.000000   0.000000 (  0.005164)
YAJL small                       0.020000   0.000000   0.020000 (  0.016937)
YAJL large                       0.940000   0.030000   0.970000 (  0.987986)
YAJL complex                     0.230000   0.010000   0.240000 (  0.233397)
YAJL long array                  0.710000   0.000000   0.710000 (  0.710261)
Ruby tiny                        0.000000   0.000000   0.000000 (  0.003004)
Ruby small                       0.000000   0.000000   0.000000 (  0.005335)
Ruby large                       0.020000   0.000000   0.020000 (  0.010745)
Ruby complex                     0.010000   0.000000   0.010000 (  0.014781)
Ruby long array                  0.030000   0.010000   0.040000 (  0.033941)
This commit is contained in:
Matt Burke 2017-05-26 14:43:49 -04:00
Родитель b5e83ef0d8
Коммит a32b6cc101
6 изменённых файлов: 9 добавлений и 99 удалений

Просмотреть файл

@ -4,4 +4,4 @@ source "https://rubygems.org"
gemspec
gem "mochilo", :git => "https://github.com/spraints/mochilo", :ref => "custom-type-registry"
gem "mochilo", :git => "https://github.com/spraints/mochilo", :ref => "symbols-and-regexps-and-time-oh-my"

Просмотреть файл

@ -1,7 +1,7 @@
GIT
remote: https://github.com/spraints/mochilo
revision: 458fcb528b704bae7bff074d9aa27ee2ccb9449d
ref: custom-type-registry
revision: 1be8e82a20a359656628439511606b7b89afa228
ref: symbols-and-regexps-and-time-oh-my
specs:
mochilo (2.0)

Просмотреть файл

@ -1,4 +1,4 @@
require "bert/mochilo"
require "mochilo"
module BERT
class Decode
@ -29,7 +29,7 @@ module BERT
end
def read_any
BERT.mochilo.unpack(@ins.read)
Mochilo.unpack(@ins.read)
end
end

Просмотреть файл

@ -1,4 +1,4 @@
require "bert/mochilo"
require "mochilo"
module BERT
class Encode
@ -49,7 +49,7 @@ module BERT
def write_any(obj)
out.write(version_header.chr)
out.write(BERT.mochilo.pack(obj))
out.write(Mochilo.pack(obj))
end
private

Просмотреть файл

@ -1,90 +0,0 @@
require "mochilo"
module BERT
def self.mochilo
@@mochilo ||= MochiloFactory.new
end
class MochiloFactory
def pack(obj)
Mochilo.pack(obj, custom_packers)
end
def unpack(str)
Mochilo.unpack(str, custom_unpackers)
end
private
def custom_packers
Hash[ customizations.map { |customization| [customization.unpacked_class, [customization.type_id, customization.method(:pack)]] } ]
end
def custom_unpackers
Hash[ customizations.map { |customization| [customization.type_id, customization.method(:unpack)] } ]
end
def customizations
@customizations ||= [
MochiloSymbol,
MochiloRegexp,
MochiloTime,
].map(&:new)
end
end
class MochiloSymbol
def unpacked_class
Symbol
end
def type_id
0x00
end
def pack(symbol)
symbol.to_s
end
def unpack(str)
str.to_sym
end
end
class MochiloRegexp
def unpacked_class
Regexp
end
def type_id
0x01
end
def pack(regexp)
[regexp.options, regexp.source].pack("Lm")
end
def unpack(raw)
options, source = raw.unpack("Lm")
Regexp.new(source, options)
end
end
class MochiloTime
def unpacked_class
Time
end
def type_id
0x02
end
def pack(time)
[time.to_f].pack("G")
end
def unpack(raw)
Time.at(raw.unpack("G").first)
end
end
end

Просмотреть файл

@ -10,11 +10,11 @@ class BertTest < Test::Unit::TestCase
@ebin_v1 = "<<131,104,9,100,0,4,117,115,101,114,104,3,100,0,4,98,101,114,116,100,0,4,100,105,99,116,108,0,0,0,1,104,2,100,0,4,110,97,109,101,109,0,0,0,3,84,80,87,106,108,0,0,0,2,104,4,100,0,4,98,101,114,116,100,0,5,114,101,103,101,120,109,0,0,0,3,99,97,116,108,0,0,0,1,100,0,8,99,97,115,101,108,101,115,115,106,99,57,46,57,48,48,48,48,48,48,48,48,48,48,48,48,48,48,101,43,48,48,0,0,0,0,0,0,0,0,0,0,106,104,5,100,0,4,98,101,114,116,100,0,4,116,105,109,101,98,0,0,4,230,98,0,14,228,195,97,0,104,2,100,0,4,98,101,114,116,100,0,3,110,105,108,104,2,100,0,4,98,101,114,116,100,0,4,116,114,117,101,104,2,100,0,4,98,101,114,116,100,0,5,102,97,108,115,101,100,0,4,116,114,117,101,100,0,5,102,97,108,115,101>>"
@berts = {
:v2 => "\x84h\td\x00\x04userh\x03d\x00\x04bertd\x00\x04dictl\x00\x00\x00\x01h\x02d\x00\x04nameq\x00\x00\x00\x03TPWjl\x00\x00\x00\x02h\x04d\x00\x04bertd\x00\x05regexq\x00\x00\x00\x03catl\x00\x00\x00\x01d\x00\bcaselessjc9.900000000000000e+00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00jh\x05d\x00\x04bertd\x00\x04timeb\x00\x00\x04\xE6b\x00\x0E\xE4\xC3a\x00h\x02d\x00\x04bertd\x00\x03nilh\x02d\x00\x04bertd\x00\x04trueh\x02d\x00\x04bertd\x00\x05falsed\x00\x04trued\x00\x05false".b,
:v3 => "\x85\x99\xC7\x05\xFF\x00user\x81\xC7\x05\xFF\x00name\xA3TPW\x92\xC7\n\xFF\x01\x01\x00\x00\x00Y2F0\n\xCB@#\xCC\xCC\xCC\xCC\xCC\xCD\xC7\t\xFF\x02A\xD2\xB3Z\x90\xC0\x00\x00\xC0\xC3\xC2\xC7\x05\xFF\x00true\xC7\x06\xFF\x00false".b,
:v3 => "\x85\x99\xC7\x06\xFF\x00user\x00\x81\xC7\x06\xFF\x00name\x00\xA3TPW\x92\xC7\x09\xFF\x01\x00\x00\x00\x01\x01cat\xCB@#\xCC\xCC\xCC\xCC\xCC\xCD\xC7\x11\xFF\x02\x00\x00\x00\x00\x4A\xCD\x6A\x43\x00\x00\x00\x00\x00\x00\x00\x00\xC0\xC3\xC2\xC7\x06\xFF\x00true\x00\xC7\x07\xFF\x00false\x00".b,
}
@ebins = {
:v2 => "<<132,104,9,100,0,4,117,115,101,114,104,3,100,0,4,98,101,114,116,100,0,4,100,105,99,116,108,0,0,0,1,104,2,100,0,4,110,97,109,101,113,0,0,0,3,84,80,87,106,108,0,0,0,2,104,4,100,0,4,98,101,114,116,100,0,5,114,101,103,101,120,113,0,0,0,3,99,97,116,108,0,0,0,1,100,0,8,99,97,115,101,108,101,115,115,106,99,57,46,57,48,48,48,48,48,48,48,48,48,48,48,48,48,48,101,43,48,48,0,0,0,0,0,0,0,0,0,0,106,104,5,100,0,4,98,101,114,116,100,0,4,116,105,109,101,98,0,0,4,230,98,0,14,228,195,97,0,104,2,100,0,4,98,101,114,116,100,0,3,110,105,108,104,2,100,0,4,98,101,114,116,100,0,4,116,114,117,101,104,2,100,0,4,98,101,114,116,100,0,5,102,97,108,115,101,100,0,4,116,114,117,101,100,0,5,102,97,108,115,101>>",
:v3 => "<<133,153,199,5,255,0,117,115,101,114,129,199,5,255,0,110,97,109,101,163,84,80,87,146,199,10,255,1,1,0,0,0,89,50,70,48,10,203,64,35,204,204,204,204,204,205,199,9,255,2,65,210,179,90,144,192,0,0,192,195,194,199,5,255,0,116,114,117,101,199,6,255,0,102,97,108,115,101>>",
:v3 => "<<133,153,199,6,255,0,117,115,101,114,0,129,199,6,255,0,110,97,109,101,0,163,84,80,87,146,199,9,255,1,0,0,0,1,1,99,97,116,203,64,35,204,204,204,204,204,205,199,17,255,2,0,0,0,0,74,205,106,67,0,0,0,0,0,0,0,0,192,195,194,199,6,255,0,116,114,117,101,0,199,7,255,0,102,97,108,115,101,0>>",
}
end