Skip to content

Instantly share code, notes, and snippets.

@jdlrobson
Created March 10, 2016 22:52
Show Gist options
  • Save jdlrobson/942ed59621d8ab1158c1 to your computer and use it in GitHub Desktop.
Save jdlrobson/942ed59621d8ab1158c1 to your computer and use it in GitHub Desktop.
profile_getText.php
<?php
require_once( '../../includes/libs/ReplacementArray.php' );
require_once( '../../includes/HtmlFormatter.php' );
function wfIsWindows () { return false; };
require_once( 'includes/MobileFormatter.php' );
const NUMBER_RUNS = 100;
$filenames = array(
'samples/blank.html',
'samples/barack.html',
'samples/nike.html',
'samples/starwars.html',
'samples/drwho.html',
'samples/geastrum.html',
'samples/oakland.html',
'samples/campus.html',
'samples/syrianwar.html',
'samples/brazil.html',
);
$removals = array(
'noremovals' => array( 'base' => array(), 'HTML' => array() ),
);
foreach ( $filenames as $i => $filename ) {
foreach( $removals as $j => $removal ) {
$total = 0;
foreach( range( 0, NUMBER_RUNS ) as $run ) {
$html = file_get_contents( $filename );
$formatter = new MobileFormatter( $html,
'Barack Obama', $removal );
$formatter->getDoc();
$then = microtime(true);
$x = $formatter->getText();
$now = microtime(true);
$elapsed = ( $now-$then );
$total += $elapsed;
}
echo sprintf("old,%s,#%s,%f\n", $filename, $j, $total / NUMBER_RUNS );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment