Пример #1
0
#!/usr/bin/php

<?php 
require_once "java/Java.inc";
ini_set("max_execution_time", 0);
$n = 200000;
$Sys = new JavaClass("java.lang.System");
$a1 = array();
for ($i = 0; $i < $n; $i++) {
    $a1[$i] = $i;
}
$Sys->gc();
$t1 = java_values($Sys->currentTimeMillis());
$v = new java("java.util.LinkedList", $a1);
$t2 = java_values($Sys->currentTimeMillis());
$T1 = $t2 - $t1;
$Sys->gc();
$t1 = java_values($Sys->currentTimeMillis());
$v = new java("java.util.HashMap", $a1);
$t2 = java_values($Sys->currentTimeMillis());
$T2 = $t2 - $t1;
$Arrays = new JavaClass("java.util.Arrays");
$Sys->gc();
$t1 = java_values($Sys->currentTimeMillis());
$v = $Arrays->asList($a1);
$t2 = java_values($Sys->currentTimeMillis());
$T3 = $t2 - $t1;
$Sys->gc();
$t1 = java_values($Sys->currentTimeMillis());
java_begin_document();
$v = new java("java.util.LinkedList");