06a429fd4e1b336a1859474d9372d53c34860aee.svn-base 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. // $Rev: 174 $
  3. error_reporting(E_ALL);
  4. include_once('../simple_html_dom.php');
  5. $dir = './html/';
  6. $files = array(
  7. array('name'=>'empty.htm', 'url'=>''),
  8. array('name'=>'smarty_1.htm', 'url'=>'guestbook.tpl'),
  9. array('name'=>'smarty_2.htm', 'url'=>'guestbook_form.tpl'),
  10. array('name'=>'google.htm', 'url'=>'http://www.google.com/'),
  11. array('name'=>'senate.htm', 'url'=>'http://www.senate.gov/legislative/LIS/roll_call_lists/roll_call_vote_cfm.cfm?congress=101&session=2&vote=00317'),
  12. array('name'=>'cyberciti.htm', 'url'=>'http://www.cyberciti.biz/tips/configure-ubuntu-grub-to-load-freebsd.html'),
  13. array('name'=>'myspace.htm', 'url'=>'http://www.myspace.com/'),
  14. array('name'=>'mootools.htm', 'url'=>'http://www.mootools.net/'),
  15. array('name'=>'jquery.htm', 'url'=>'http://jquery.com/'),
  16. array('name'=>'scriptaculo.htm', 'url'=>'http://script.aculo.us/'),
  17. array('name'=>'apache.htm', 'url'=>'http://www.apache.org/'),
  18. array('name'=>'microsoft.htm', 'url'=>'http://www.microsoft.com/'),
  19. array('name'=>'slashdot.htm', 'url'=>'http://www.slashdot.org/'),
  20. array('name'=>'ror.htm', 'url'=>'http://www.rubyonrails.org/'),
  21. array('name'=>'yahoo.htm', 'url'=>'http://www.yahoo.com/'),
  22. array('name'=>'phpbb.htm', 'url'=>'http://www.phpbb.com/'),
  23. array('name'=>'python.htm', 'url'=>'http://www.python.org/'),
  24. array('name'=>'lua.htm', 'url'=>'http://www.lua.org/'),
  25. array('name'=>'php.htm', 'url'=>'http://www.php.net/'),
  26. array('name'=>'ibm.htm', 'url'=>'http://www.ibm.com/'),
  27. array('name'=>'java.htm', 'url'=>'http://java.sun.com/'),
  28. array('name'=>'flickr.htm', 'url'=>'http://www.flickr.com/tour/upload/'),
  29. array('name'=>'amazon.htm', 'url'=>'http://www.amazon.com/'),
  30. array('name'=>'youtube.htm', 'url'=>'http://www.youtube.com/watch?v=kib05Ip6GSo&feature=bz302'),
  31. );
  32. echo 'memory: '.memory_get_usage().'<br>';
  33. $dom = new simple_html_dom;
  34. foreach($files as $f) {
  35. // get file from url
  36. if($f['url']!='') file_put_contents($dir.$f['name'], file_get_contents($f['url']));
  37. else file_put_contents($dir.$f['name'], '');
  38. $start = microtime();
  39. $dom->load(file_get_contents($dir.$f['name']), false);
  40. list($eu, $es) = explode(' ', microtime());
  41. list($bu, $bs) = explode(' ', $start);
  42. echo sprintf('(%.1f)', ((float)$eu+(float)$es-(float)$bu-(float)$bs)*1000).'<br>';
  43. if (file_get_contents($dir.$f['name'])!=$dom->save()) {
  44. echo "[<font color='red'>failed</font>] ".$f['name']."<br>";
  45. $dom->save($dir.$f['name'].'.error');
  46. }
  47. else
  48. echo "[success] ".$f['name']."<br>";
  49. echo 'memory: '.memory_get_usage().'<br>';
  50. flush();
  51. set_time_limit(0);
  52. }
  53. $dom->clear();
  54. unset($dom);
  55. echo '<br>memory: '.memory_get_usage().'<br>';
  56. ?>