Skip to content

Instantly share code, notes, and snippets.

@jlogsdon
Created April 7, 2012 18:20
Show Gist options
  • Save jlogsdon/2331111 to your computer and use it in GitHub Desktop.
Save jlogsdon/2331111 to your computer and use it in GitHub Desktop.
Small test script to test table generation with more than a few rows and columns.
<?php
if (php_sapi_name() != 'cli') {
die('Must run from command line');
}
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
ini_set('log_errors', 0);
ini_set('html_errors', 0);
require 'lib/cli/cli.php';
\cli\register_autoload();
$headers = array('One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten');
$colors = array('Y', 'G', 'B', 'R', 'P', 'M', 'C', 'W', 'K');
$table = new \cli\Table();
$table->setHeaders($headers);
while(true) {
$data = array();
for ($r = 0; $r < 100; $r++) {
$data[$r] = array();
for ($c = 0; $c < 10; $c++) {
$color = rand(0, 8);
$data[$r][$c] = '%' . $colors[$color] . str_repeat('a', rand(10, 20)) . '%n';
}
}
$start = microtime(true);
$table->setRows($data);
$table->display();
$elapsed = microtime(true) - $start;
echo "Rendered in $elapsed seconds\n";
usleep(500000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment