<commit_before><?php
/*
 * Timing class
 * Measures times and logs them into log file
 *
 * Examples:
 *      // Create new Timing class with \n break
 *      $timing = new Timing("\n");
 * 
 *      // Start timing
 *      $timing->start();
 * 
 *      // Loop ten rounds and sleep one second per round
 *      for ($i=1;$i<=10;$i++) { 
 *          echo $i . "\t"; sleep(1);
 *          // Print elapsed time every 2 rounds
 *          if ($i%2==0) {
 *              $timing->printElapsedTime();
 *          }
 *      }
 * 
 *      // Stop/end timing
 *      $timing->stop();
 * 
 *      // Print only total execution time
 *      $timing->printTotalExecutionTime();
 * 
 *      // Print full stats
 *      $timing->printFullStats(); 
 *      
 *      http://www.if-not-true-then-false.com/2010/php-timing-class-class-for-measure-php-scripts-execution-time-and-php-web-page-load-time/
 */
class Timing {
    private $file; // log reference
    private $filename; // log filename
    private $directory; // directory for log file
    private $break;
    private $start_time;
    private $stop_time;
    private $prev;

    // Constructor for Timing class
    public function __construct($name, $dir = 'log/', $break = "\n") {
        $this->break = $break;
        $this->filename = $name;
        $this->directory = $dir;
        if(TIMING == true) {
            echo 'hello';
            $this->file = fopen($this->directory.$this->filename, 'a');
            $this->newRequest();
        }
        // Set timezone
        date_default_timezone_set('UTC');
    }

    /*
     * Private: Create new log request with header detailing request
     */
    private function newRequest() {
            echo 'hello';
        ob_start(); ?>

/*
 * Request Method: <?php echo $_SERVER['REQUEST_METHOD']; ?> 
 * Request Time: <?php echo $_SERVER['REQUEST_TIME']; ?> 
 * Query String: <?php echo $_SERVER['QUERY_STRING']; ?> 
 * Http Referer: <?php echo $_SERVER['HTTP_REFERER']; ?> 
 * Http User Agent: <?php echo $_SERVER['HTTP_USER_AGENT']; ?> 
 * Remote Address: <?php echo $_SERVER['REMOTE_ADDR']; ?> 
 * Server Port: <?php echo $_SERVER['SERVER_PORT']; ?> 
 * Script Name: <?php echo $_SERVER['SCRIPT_NAME']; ?> 
 * Request Uri: <?php echo $_SERVER['REQUEST_URI']; ?> 
 * <?php echo date("Y-m-d H:i:s"); ?>\n
 */
Start  Prev
<?php 
        $header = ob_get_contents();
        ob_end_clean();
        fwrite($this->file, $header);
        $this->start();
    }

    /*
     * Public: New log marker
     */
    public function log($label) {
        if(TIMING) {<commit_msg>Removed some debugging<commit_after><?php
/*
 * Timing class
 * Measures times and logs them into log file
 *
 * Examples:
 *      // Create new Timing class with \n break
 *      $timing = new Timing("\n");
 * 
 *      // Start timing
 *      $timing->start();
 * 
 *      // Loop ten rounds and sleep one second per round
 *      for ($i=1;$i<=10;$i++) { 
 *          echo $i . "\t"; sleep(1);
 *          // Print elapsed time every 2 rounds
 *          if ($i%2==0) {
 *              $timing->printElapsedTime();
 *          }
 *      }
 * 
 *      // Stop/end timing
 *      $timing->stop();
 * 
 *      // Print only total execution time
 *      $timing->printTotalExecutionTime();
 * 
 *      // Print full stats
 *      $timing->printFullStats(); 
 *      
 *      http://www.if-not-true-then-false.com/2010/php-timing-class-class-for-measure-php-scripts-execution-time-and-php-web-page-load-time/
 */
class Timing {
    private $file; // log reference
    private $filename; // log filename
    private $directory; // directory for log file
    private $break;
    private $start_time;
    private $stop_time;
    private $prev;

    // Constructor for Timing class
    public function __construct($name, $dir = 'log/', $break = "\n") {
        $this->break = $break;
        $this->filename = $name;
        $this->directory = $dir;
        if(TIMING == true) {
            $this->file = fopen($this->directory.$this->filename, 'a');
            $this->newRequest();
        }
        // Set timezone
        date_default_timezone_set('UTC');
    }

    /*
     * Private: Create new log request with header detailing request
     */
    private function newRequest() {
        ob_start(); ?>

/*
 * Request Method: <?php echo $_SERVER['REQUEST_METHOD']; ?> 
 * Request Time: <?php echo $_SERVER['REQUEST_TIME']; ?> 
 * Query String: <?php echo $_SERVER['QUERY_STRING']; ?> 
 * Http Referer: <?php echo $_SERVER['HTTP_REFERER']; ?> 
 * Http User Agent: <?php echo $_SERVER['HTTP_USER_AGENT']; ?> 
 * Remote Address: <?php echo $_SERVER['REMOTE_ADDR']; ?> 
 * Server Port: <?php echo $_SERVER['SERVER_PORT']; ?> 
 * Script Name: <?php echo $_SERVER['SCRIPT_NAME']; ?> 
 * Request Uri: <?php echo $_SERVER['REQUEST_URI']; ?> 
 * <?php echo date("Y-m-d H:i:s"); ?>\n
 */
Start  Prev
<?php 
        $header = ob_get_contents();
        ob_end_clean();
        fwrite($this->file, $header);
        $this->start();
    }

    /*
     * Public: New log marker
     */
    public function log($label) {
        if(TIMING) {
{'fraction_non_alphanumeric': 0.1676153091265947, 'fraction_numerical': 0.0043179587831207065, 'mean_word_length': 2.260396673064619, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6093931', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1553, 'n_words': 394}