Login   Register  
PHP Classes
elePHPant
Icontem

File: speed_test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Rolands Kusins  >  PHP Luhn Algorithm  >  speed_test.php  >  Download  
File: speed_test.php
Role: Example script
Content type: text/plain
Description: Speed test example
Class: PHP Luhn Algorithm
Calculate and validate a Luhn check digit
Author: By
Last change:
Date: 10 months ago
Size: 770 bytes
 

Contents

Class file image Download
<!DOCTYPE html>
<html>
<head>
    <title>Luhn's algorithm speed test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
    <div>
        <pre>
<?php
include_once 'Luhn.php';
$luhn = new Luhn();

// New method, see http://www.phpclasses.org/discuss/package/8471/thread/1/
$startTime microtime(true);
$number "38972438297432";
for(
$i=0;$i<1000000;$i++){
    
$checkDigit $luhn->calculate($number.$i);
}
$endTime microtime(true);
echo 
"time1: ".($endTime-$startTime)." sec\n";

// Old method
$startTime microtime(true);
$number "38972438297432";
for(
$i=0;$i<1000000;$i++){
    
$checkDigit $luhn->calculateOld($number.$i);
}
$endTime microtime(true);
echo 
"time2: ".($endTime-$startTime)." sec\n";
?>
        </pre>
    </div>
</body>
</html>