<commit_before><?php
/*
Copyright 2010 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

require_once("./batch_lib.inc");
require_once("./bootstrap.inc");

// A file lock to guarantee there is only one instance running.
$fp = fopen($gLockFile, "w+");
if ( !flock($fp, LOCK_EX | LOCK_NB) ) {
	echo "There is one instance running already!\r\n";
	reportSummary();
	exit(-1);
}

if ( ! tableExists($gStatusTable) ) {
	echo "Please run batch_start to kick off a new batch!";
	exit(-2);
}


$pid_arr = array();
for ( $i = 0; $i < 5; $i++ ) {
	$pid = pcntl_fork();
	if ( -1 == $pid ) {
		die("cannot fork subprocesses ...");
	} else {
		if ( $pid ) {
			// Parent process
			$pid_arr[] = $pid;
		} elseif ( 0 == $i ) {
			submitBatch();
			exit();
		} elseif ( 1 == $i ) {
			// Check the test status with WPT server
			checkWPTStatus();
			exit();
		} elseif ( 2 == $i ) {
			// Obtain XML result
			obtainXMLResult();
			exit();
		} elseif ( 3 == $i ) {
			// Download har file
			downloadHar();
			exit();
		} elseif ( 4 == $i ) {
			// Fill page table and request table
			fillTables();
			exit();
		}
	}
}

while ( count($pid_arr) > 0 ) {
	$myId = pcntl_waitpid(-1, $status, WNOHANG);
	foreach ( $pid_arr as $key => $pid ) {
		if ( $myId == $pid ) {
			unset($pid_arr[$key]);
		}
	}
	usleep(100);
}

reportSummary();

?><commit_msg>Remove the phase and process for downloading HAR files.<commit_after><?php
/*
Copyright 2010 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

require_once("../utils.php");
require_once("batch_lib.inc");
require_once("bootstrap.inc");


// A file lock to guarantee there is only one instance running.
$fp = fopen($gLockFile, "w+");
if ( !flock($fp, LOCK_EX | LOCK_NB) ) {
	echo "There is one instance running already!\r\n";
	reportSummary();
	exit(-1);
}

if ( ! tableExists($gStatusTable) ) {
	echo "Please run batch_start to kick off a new batch!";
	exit(-2);
}


$pid_arr = array();
for ( $i = 0; $i < 4; $i++ ) {
	$pid = pcntl_fork();
	if ( -1 == $pid ) {
		die("cannot fork subprocesses ...");
	} else {
		if ( $pid ) {
			// Parent process
			$pid_arr[] = $pid;
		} elseif ( 0 == $i ) {
			submitBatch();
			exit();
		} elseif ( 1 == $i ) {
			// Check the test status with WPT server
			checkWPTStatus();
			exit();
		} elseif ( 2 == $i ) {
			// Obtain XML result
			obtainXMLResult();
			exit();
		} elseif ( 3 == $i ) {
			// Fill page table and request table
			fillTables();
			exit();
		}
	}
}

// Loop through the processes until all of them are done and then exit.
while ( count($pid_arr) > 0 ) {
	$myId = pcntl_waitpid(-1, $status, WNOHANG);
	foreach ( $pid_arr as $key => $pid ) {
		if ( $myId == $pid ) {
echo "\n\nCVSNO: unsetting $key => $pid\n\n";
			unset($pid_arr[$key]);
		}
	}
	usleep(100);
}

reportSummary();

?>
{'fraction_non_alphanumeric': 0.1497468691713296, 'fraction_numerical': 0.011990407673860911, 'mean_word_length': 3.265909090909091, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5185821', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1269, 'n_words': 439}