<commit_before><?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 PHP_EOL;
}

echo "# array() // $arraySize".PHP_EOL;
perf_begin();
$arr = [];
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;
<commit_msg>momory_limit = 1<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;

ini_set('memory_limit', -1);
$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 PHP_EOL;
}

echo "# array() // $arraySize".PHP_EOL;
perf_begin();
$arr = [];
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.19268849961919268, 'fraction_numerical': 0.028941355674028942, 'mean_word_length': 4.233067729083666, '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': '4505358', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1071, 'n_words': 213}