示例#1
0
文件: hash1.php 项目: michaelprem/phc
    return $t['sec'] + $t['usec'] / 1000000;
}
function start_test()
{
    ob_start();
    return getmicrotime();
}
function end_test($start, $name)
{
    global $total;
    $end = getmicrotime();
    ob_end_clean();
    $total += $end - $start;
    $num = number_format($end - $start, 3);
    $pad = str_repeat(" ", 24 - strlen($name) - strlen($num));
    echo $name . $pad . $num . "\n";
    ob_start();
    return getmicrotime();
}
function total()
{
    global $total;
    $pad = str_repeat("-", 24);
    echo $pad . "\n";
    $num = number_format($total, 3);
    $pad = str_repeat(" ", 24 - strlen("Total") - strlen($num));
    echo "Total" . $pad . $num . "\n";
}
$t0 = $t = start_test();
hash1(590000);
$t = end_test($t, "hash1(50000)");
示例#2
0
simpleudcall();
$t = end_test($t, "simpleudcall");
mandel();
$t = end_test($t, "mandel");
mandel2();
$t = end_test($t, "mandel2");
ackermann(7);
$t = end_test($t, "ackermann(7)");
ary(50000);
$t = end_test($t, "ary(50000)");
ary2(50000);
$t = end_test($t, "ary2(50000)");
ary3(2000);
$t = end_test($t, "ary3(2000)");
fibo(30);
$t = end_test($t, "fibo(30)");
hash1(50000);
$t = end_test($t, "hash1(50000)");
hash2(500);
$t = end_test($t, "hash2(500)");
heapsort(20000);
$t = end_test($t, "heapsort(20000)");
matrix(20);
$t = end_test($t, "matrix(20)");
nestedloop(12);
$t = end_test($t, "nestedloop(12)");
sieve(30);
$t = end_test($t, "sieve(30)");
strcat(200000);
$t = end_test($t, "strcat(200000)");
total($t0, "Total");
示例#3
0
<?php

function hash1($n)
{
    for ($i = 1; $i <= $n; $i++) {
        $X[dechex($i)] = $i;
    }
    $c = 0;
    for ($i = $n; $i > 0; $i--) {
        if ($X[dechex($i)]) {
            $c++;
        }
    }
    print "{$c}\n";
}
hash1(5);
示例#4
0
function main_function()
{
    for ($i = 0; $i < 100; ++$i) {
        ackermann(4);
        ary(50000);
        ary2(50000);
        ary3(100);
        fibo(23);
        hash1(10000);
        hash2(200);
        heapsort(2000);
        matrix(3);
        nestedloop(8);
        sieve(5);
        strcat(80000);
        binary_trees(7);
        fannkuch(6);
    }
}
示例#5
0
     $passworderr = "Please enter a valid password which is atleast 6 characters and contains one letter and number";
     $valid6 = False;
 } else {
     $password = $_POST["password"];
     $valid6 = True;
 }
 if ($password == $_POST["confirmpassword"]) {
     $valid7 = True;
 } else {
     $confirmerr = "Please enter the same password in the confirm password field";
     $valid7 = False;
 }
 // if all data entered is valid
 if ($valid1 && $valid2 && $valid3 && $valid4 && $valid5 && $valid6 && $valid7) {
     // encrypt the password
     $hash_value = hash1($password);
     //connect to database
     try {
         $conn = new PDO("mysql:host={$servername};dbname={$database}", $database_username, $database_password);
         // set the PDO error mode to exception
         $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
         echo "Connection failed: " . $e->getMessage();
     }
     //insert data into database
     $sql = "INSERT INTO users(Title,Firstname,Surname,Username,EmailAddress,Password)  VALUES ('{$title}','{$firstName}','{$surname}','{$username}','{$email}','{$hash_value}')";
     $conn->query($sql);
     echo "\n                             <script>\n\n                              alert('Registration has been successful! Please go to the homepage to login ');\n\n                             </script> ";
     $conn = null;
     echo "<script> window.location.assign('index.php'); </script>";
     exit;
示例#6
0
function main_function()
{
    ackermann(2);
    ary(500);
    ary2(500);
    ary3(5);
    fibo(13);
    hash1(100);
    hash2(20);
    heapsort(200);
    matrix(3);
    nestedloop(3);
    sieve(1);
    strcat(80);
    binary_trees(3);
    fannkuch(6);
}