<commit_before><?php

if (is_readable('vendor/autoload.php')) {
    require 'vendor/autoload.php';
} else {
    require_once 'Array/Uint8.php';
}

$prev_mem = $prev_time = null;

$arraySize = 1024*1024;

function perf_begin() {
    global $prev_mem, $prev_time;
    $prev_mem = memory_get_usage();
    $prev_time = microtime(true);
}

function perf_end() {
    global $prev_mem, $prev_time;
    echo '  memory:'. (memory_get_usage() - $prev_mem )  . PHP_EOL;
    echo '  time:'  . (microtime(true)    - $prev_time). PHP_EOL;
}

echo "# array() // $arraySize".PHP_EOL;
perf_begin();
$arr = array();
foreach (range(0, $arraySize - 1) as $i) { $arr[] = 255; }
perf_end();
$arr = null;

echo "# SplFixedArray($arraySize)".PHP_EOL;
perf_begin();
$arr = new SplFixedArray($arraySize);
foreach (range(0, $arraySize - 1) as $i) { $arr[$i] = 255; }
perf_end();
$arr = null;

echo "# Array_Uint8($arraySize)".PHP_EOL;
perf_begin();
$arr = new Array_Uint8($arraySize);
foreach (range(0, $arraySize - 1) as $i) { $arr[$i] = 255; }
perf_end();
$arr = null;<commit_msg>Sint16 のテストを追加<commit_after><?php

if (is_readable('vendor/autoload.php')) {
    require 'vendor/autoload.php';
} else {
    require_once 'Array/Uint8.php';
    require_once 'Array/Sint16.php';
}

$prev_mem = $prev_time = null;

$arraySize = 1024*1024;

function perf_begin() {
    global $prev_mem, $prev_time;
    $prev_mem = memory_get_usage();
    $prev_time = microtime(true);
}

function perf_end() {
    global $prev_mem, $prev_time;
    echo '  memory:'. (memory_get_usage() - $prev_mem )  . PHP_EOL;
    echo '  time:'  . (microtime(true)    - $prev_time). PHP_EOL;
}

echo "# array() // $arraySize".PHP_EOL;
perf_begin();
$arr = array();
foreach (range(0, $arraySize - 1) as $i) { $arr[] = 255; }
perf_end();
$arr = null;

echo "# SplFixedArray($arraySize)".PHP_EOL;
perf_begin();
$arr = new SplFixedArray($arraySize);
foreach (range(0, $arraySize - 1) as $i) { $arr[$i] = 255; }
perf_end();
$arr = null;

echo "# Array_Uint8($arraySize)".PHP_EOL;
perf_begin();
$arr = new Array_Uint8($arraySize);
foreach (range(0, $arraySize - 1) as $i) { $arr[$i] = 255; }
perf_end();
$arr = null;

echo "# Array_Sint16($arraySize)".PHP_EOL;
perf_begin();
$arr = new Array_Sint16($arraySize);
foreach (range(0, $arraySize - 1) as $i) { $arr[$i] = -255; }
perf_end();
$arr = null;
{'fraction_non_alphanumeric': 0.19356223175965664, 'fraction_numerical': 0.027896995708154508, 'mean_word_length': 4.420930232558139, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3697926', 'n_tokens_mistral': 987, 'n_tokens_neox': 934, 'n_words': 195}