MessagePack\Tests\DataProvider::provideData PHP Method

provideData() public static method

public static provideData ( )
    public static function provideData()
    {
        return [['nil', null, "�"], ['false', false, "�"], ['true', true, "�"], ['7-bit uint #1', 0x0, ""], ['7-bit uint #2', 0x10, ""], ['7-bit uint #3', 0x7f, ""], ['5-bit sint #1', -1, "�"], ['5-bit sint #2', -16, "�"], ['5-bit sint #3', -32, "�"], ['8-bit uint #1', 0x80, "̀"], ['8-bit uint #2', 0xf0, "��"], ['8-bit uint #3', 0xff, "��"], ['16-bit uint #1', 0x100, "�"], ['16-bit uint #2', 0x2000, "� "], ['16-bit uint #3', 0xffff, "���"], ['32-bit uint #1', 0x10000, "�"], ['32-bit uint #2', 0x200000, "� "], ['32-bit uint #3', 4294967295.0, "�����"], ['64-bit uint #1', 4294967296.0, "�" . "" . ""], ['64-bit uint #2', 9.223372036854776E+18, "�" . "���" . "����"], ['8-bit int #1', -33, "��"], ['8-bit int #2', -100, "М"], ['8-bit int #3', -128, "Ѐ"], ['16-bit int #1', -129, "��"], ['16-bit int #2', -2000, "��0"], ['16-bit int #3', -32768, "р"], ['32-bit int #1', -32769, "����"], ['32-bit int #2', -1000000000, "��e6"], ['32-bit int #3', -2147483648.0, "Ҁ"], ['64-bit int #1', -2147483649.0, "�" . "����" . "���"], ['64-bit int #2', -1.0E+18, "�" . "�IL" . "X���"], ['64-bit int #3', (int) '-9223372036854775808', "�" . "�" . ""], ['64-bit float #1', 0.0, "�" . "" . ""], ['64-bit float #2', 2.5, "�" . "@" . ""], ['64-bit float #3', pow(10, 35), "�" . "G3Ba" . "r�M�"], ['fix string #1', '', "�"], ['fix string #2', 'a', "�a"], ['fix string #3', 'abc', "�abc"], ['fix string #4', str_repeat('a', 31), "�" . str_repeat("a", 31)], ['8-bit string #1', str_repeat('b', 32), "� " . str_repeat('b', 32)], ['8-bit string #2', str_repeat('c', 100), "�d" . str_repeat('c', 100)], ['8-bit string #3', str_repeat('d', 255), "��" . str_repeat('d', 255)], ['16-bit string #1', str_repeat('b', 256), "�" . str_repeat('b', 256)], ['16-bit string #2', str_repeat('c', 65535), "���" . str_repeat('c', 65535)], ['32-bit string', str_repeat('b', 65536), "�" . str_repeat('b', 65536)], ['wide char string #1', 'Allagbé', "�Allagbé"], ['wide char string #2', 'По оживлённым берегам', "�(По оживлённым берегам"], ['8-bit binary #1', "�", "�" . "�"], ['8-bit binary #2', str_repeat("�", 32), "� " . str_repeat("�", 32)], ['8-bit binary #3', str_repeat("�", 255), "��" . str_repeat("�", 255)], ['16-bit binary', str_repeat("�", 256), "�" . str_repeat("�", 256)], ['32-bit binary', str_repeat("�", 65536), "�" . str_repeat("�", 65536)], ['fixext 1', new Ext(5, "�"), "�" . "�"], ['fixext 2', new Ext(5, str_repeat("�", 2)), "�" . str_repeat("�", 2)], ['fixext 4', new Ext(5, str_repeat("�", 4)), "�" . str_repeat("�", 4)], ['fixext 8', new Ext(5, str_repeat("�", 8)), "�" . str_repeat("�", 8)], ['fixext 16', new Ext(5, str_repeat("�", 16)), "�" . str_repeat("�", 16)], ['8-bit ext', new Ext(5, str_repeat("�", 255)), "��" . str_repeat("�", 255)], ['16-bit ext', new Ext(5, str_repeat("�", 256)), "�" . str_repeat("�", 256)], ['32-bit ext', new Ext(5, str_repeat("�", 65536)), "�" . str_repeat("�", 65536)], ['fix array #1', [], "�"], ['fix array #2', [5, 'abc', true], "��abc�"], ['16-bit array #1', array_fill(0, 16, 0x5), "�" . str_repeat("", 16)], ['16-bit array #2', array_fill(0, 65535, 0x5), "���" . str_repeat("", 65535)], ['32-bit array', array_fill(0, 65536, 0x5), "�" . str_repeat("", 65536)], ['complex array', [true, 0x1, new Ext(3, 'foo'), 0xff, [1 => false, 2 => 'abc'], "�", [1, 2, 3], 'abc'], "���foo�����abc����abc"], ['fix map #1', [1 => true, 2 => 'abc', 3 => "�", 4 => null], "���abc���"], ['fix map #2', ['abc' => 5], "��abc"], ['fix map #3', ["�" => 0xffff], "������"], ['fix map #4', [-1 => -1, 1 => 1], "���"], ['16-bit map #1', array_fill(1, 16, 0x5), "�" . array_reduce(range(1, 16), function ($r, $i) {
            return $r .= pack('C', $i) . "";
        })], ['16-bit map #2', array_fill(1, 65535, 0x5), "���" . array_reduce(range(1, 127), function ($r, $i) {
            return $r .= pack('C', $i) . "";
        }) . array_reduce(range(128, 255), function ($r, $i) {
            return $r .= "�" . pack('C', $i) . "";
        }) . array_reduce(range(256, 65535), function ($r, $i) {
            return $r .= "�" . pack('n', $i) . "";
        })], ['32-bit map', array_fill(1, 65536, 0x5), "�" . array_reduce(range(1, 127), function ($r, $i) {
            return $r .= pack('C', $i) . "";
        }) . array_reduce(range(128, 255), function ($r, $i) {
            return $r .= "�" . pack('C', $i) . "";
        }) . array_reduce(range(256, 65535), function ($r, $i) {
            return $r .= "�" . pack('n', $i) . "";
        }) . "�" . pack('N', 65536) . ""], ['complex map', [1 => [[1 => 2, 3 => 4], [1 => null]], 2 => 1, 3 => [false, 'def'], 4 => [4294967296.0 => 'a', 4294967295.0 => 'b']], "������£def���a������b"]];
    }

Usage Example

Example #1
0
$testNames = getenv('MP_BENCH_TESTS') ?: '-16-bit array #2, -32-bit array, -16-bit map #2, -32-bit map';
$benchmark = getenv('MP_BENCH_DURATION') ? new DurationBenchmark(getenv('MP_BENCH_DURATION')) : new IterationBenchmark(getenv('MP_BENCH_ITERATIONS') ?: 100000);
if ($rounds) {
    $benchmark = new AverageableBenchmark($benchmark, $rounds);
}
if ($testNames) {
    $filter = '/' === $testNames[0] ? new RegexpFilter($testNames) : new ListFilter(explode(',', $testNames));
    $benchmark = new FilterableBenchmark($benchmark, $filter);
}
$targetFactories = ['pecl_p' => function () {
    return new PeclFunctionPackTarget();
}, 'pecl_u' => function () {
    return new PeclFunctionUnpackTarget();
}, 'pure_p' => function () {
    return new PackerTarget('Packer');
}, 'pure_ps' => function () {
    return new PackerTarget('Packer (str)', new Packer(Packer::FORCE_STR));
}, 'pure_pa' => function () {
    return new PackerTarget('Packer (arr)', new Packer(Packer::FORCE_ARR));
}, 'pure_psa' => function () {
    return new PackerTarget('Packer (str|arr)', new Packer(Packer::FORCE_STR | Packer::FORCE_ARR));
}, 'pure_bu' => function () {
    return new BufferUnpackerTarget('BufferUnpacker');
}];
$targets = [];
foreach (explode(',', $targetAliases) as $alias) {
    $targets[] = $targetFactories[trim($alias)]();
}
$runner = new Runner(DataProvider::provideData());
gc_disable();
$runner->run($benchmark, $targets);