示例#1
0
$max = 10 * $scale;
$aco_list = $gacl_api->get_object('system', 1, 'ACO');
$query = 'SELECT id, name FROM ' . $gacl_api->_db_table_prefix . '' . $gacl_ . 'aro_groups ORDER BY parent_id DESC LIMIT 100';
$rs = $gacl_api->db->Execute($query);
$aro_groups = $rs->GetAssoc();
$query = 'SELECT id, name FROM ' . $gacl_api->_db_table_prefix . 'axo_groups ORDER BY parent_id DESC LIMIT 100';
$rs = $gacl_api->db->Execute($query);
$axo_groups = $rs->GetAssoc();
// $aro_groups = $gacl_api->format_groups ($gacl_api->sort_groups ('ARO'), 'ARRAY');
print_r($aro_groups);
// $axo_groups = $gacl_api->format_groups ($gacl_api->sort_groups ('AXO'), 'ARRAY');
print_r($axo_groups);
for ($i = $start; $i <= $max; $i++) {
    $rand_aco_key = array_mt_rand($aco_list, mt_rand(2, 10));
    $rand_aro_key = array_mt_rand($aro_groups, mt_rand(2, 10));
    $rand_axo_key = array_mt_rand($axo_groups, mt_rand(2, 10));
    $aco_array = array();
    foreach ($rand_aco_key as $aco_key) {
        $aco_data = $gacl_api->get_object_data($aco_list[$aco_key], 'ACO');
        $aco_array[$aco_data[0][0]][] = $aco_data[0][1];
    }
    // Randomly create ACLs with AXOs assigned to them.
    // if ($i % 2 == 0) {
    $axo_array = $rand_axo_key;
    // }
    if ($gacl_api->add_acl($aco_array, NULL, $rand_aro_key, NULL, $axo_array) == FALSE) {
        echo "    Error creating ACL: {$i}.\n";
        echo '    ' . $gacl_api->_debug_msg . "\n";
        // print_r (array_slice ($gacl_api->_debug_msg, -2));
    }
    unset($axo_array);
$overall_start = getmicrotime();
mt_srand((double) microtime() * 10000);
echo "<b>Generating Test Data Set</b>\n";
flush();
$start_time = getmicrotime();
$start = 1;
$max = 5 * $scale;
// $max = 1;
$check = array();
$aco = random_objects('aco', $max);
$aro = random_objects('aro', $max);
$axo = random_objects('axo', $max);
for ($i = $start; $i <= $max; $i++) {
    $rand_aco_id = array_mt_rand($aco, 1);
    $rand_aro_id = array_mt_rand($aro, 1);
    $rand_axo_id = array_mt_rand($axo, 1);
    // echo '    Rand ACO: '. $rand_aco_id .' ARO: '. $rand_aro_id . ' AXO: ' . $rand_axo_id . "\n";
    $check[$i] = array('aco' => $aco[$rand_aco_id], 'aro' => $aro[$rand_aro_id], 'axo' => $axo[$rand_axo_id]);
}
$elapsed = getmicrotime() - $start_time;
echo "Done\n\n";
echo '    Count:   ' . $max . "\n";
echo '    Time:    ' . $elapsed . " s\n";
echo '    Average: ' . $elapsed / $max . " s\n\n";
echo "<b>Testing...</b>\n";
flush();
$best = 99999;
$worst = 0;
$total = 0;
$allowed = 0;
$denied = 0;