本文整理汇总了PHP中pts_openbenchmarking::make_openbenchmarking_request方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_openbenchmarking::make_openbenchmarking_request方法的具体用法?PHP pts_openbenchmarking::make_openbenchmarking_request怎么用?PHP pts_openbenchmarking::make_openbenchmarking_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_openbenchmarking
的用法示例。
在下文中一共展示了pts_openbenchmarking::make_openbenchmarking_request方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($r)
{
pts_client::$display->generic_heading('Recommended OpenBenchmarking.org Test Profiles');
$test_count = 0;
$recommendation_index = pts_openbenchmarking::make_openbenchmarking_request('recommended_tests_index');
$recommendation_index = json_decode($recommendation_index, true);
foreach ($recommendation_index['recommended_tests'] as $subsystem => $tests) {
pts_client::$display->generic_heading($subsystem . ' Tests');
foreach ($tests as $test) {
echo sprintf('%-32ls - %-35ls', $test['test_profile'], $test['title']) . PHP_EOL;
}
$test_count++;
}
if ($test_count == 0) {
echo PHP_EOL . 'No tests found. Please check that you have Internet connectivity to download test profile data from OpenBenchmarking.org. The Phoronix Test Suite has documentation on configuring the network setup, proxy settings, and PHP network options. Please contact Phoronix Media if you continuing to experience problems.' . PHP_EOL . PHP_EOL;
}
}
示例2: run
public static function run($r)
{
if (pts_openbenchmarking_client::user_name() == false) {
echo PHP_EOL . 'You must first be logged into an OpenBenchmarking.org account.' . PHP_EOL;
echo PHP_EOL . 'Create An Account: http://openbenchmarking.org/';
echo PHP_EOL . 'Log-In Command: phoronix-test-suite openbenchmarking-setup' . PHP_EOL . PHP_EOL;
return false;
}
foreach (pts_types::identifiers_to_test_profile_objects($r, true, true) as $test_profile) {
// validate_test_profile
if (pts_validation::validate_test_profile($test_profile)) {
pts_client::$display->generic_heading($test_profile);
$zip_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . $test_profile->get_identifier_base_name() . '-' . $test_profile->get_test_profile_version() . '.zip';
$zip_created = pts_compression::zip_archive_create($zip_file, pts_file_io::glob($test_profile->get_resource_dir() . '*'));
if ($zip_created == false) {
echo PHP_EOL . 'Failed to create zip file.' . PHP_EOL;
return false;
}
if (filesize($zip_file) > 104857) {
echo PHP_EOL . 'The test profile package is too big.' . PHP_EOL;
return false;
}
$commit_description = pts_user_io::prompt_user_input('Enter a test commit description', false);
echo PHP_EOL;
$server_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_profile', array('tp_identifier' => $test_profile->get_identifier_base_name(), 'tp_sha1' => sha1_file($zip_file), 'tp_zip' => base64_encode(file_get_contents($zip_file)), 'tp_zip_name' => basename($zip_file), 'commit_description' => $commit_description));
echo PHP_EOL;
$json = json_decode($server_response, true);
if (isset($json['openbenchmarking']['upload']['error']) && !empty($json['openbenchmarking']['upload']['error'])) {
echo 'ERROR: ' . $json['openbenchmarking']['upload']['error'] . PHP_EOL;
}
if (isset($json['openbenchmarking']['upload']['id']) && !empty($json['openbenchmarking']['upload']['id'])) {
echo 'Command: phoronix-test-suite benchmark ' . $json['openbenchmarking']['upload']['id'] . PHP_EOL;
}
if (isset($json['openbenchmarking']['upload']['url']) && !empty($json['openbenchmarking']['upload']['url'])) {
pts_openbenchmarking::refresh_repository_lists(null, true);
echo 'URL: ' . $json['openbenchmarking']['upload']['url'] . PHP_EOL;
}
echo PHP_EOL;
// TODO: chmod +x the .sh files, appropriate permissions elsewhere
unlink($zip_file);
}
}
}
示例3: run
public static function run($r)
{
echo PHP_EOL . 'If you have not already registered for your free OpenBenchmarking.org account, you can do so at http://openbenchmarking.org/' . PHP_EOL . PHP_EOL . 'Once you have registered your account and clicked the link within the verification email, enter your log-in information below.' . PHP_EOL . PHP_EOL;
echo 'User-Name: ';
$username = pts_user_io::read_user_input();
echo 'Password: ';
$password = pts_user_io::read_user_input();
$login_payload = array('s_u' => $username, 's_p' => sha1($password), 's_s' => base64_encode(phodevi::system_software(true)), 's_h' => base64_encode(phodevi::system_hardware(true)));
$login_state = pts_openbenchmarking::make_openbenchmarking_request('account_login', $login_payload);
$json = json_decode($login_state, true);
if (isset($json['openbenchmarking']['response']['error'])) {
trigger_error($json['openbenchmarking']['response']['error'], E_USER_ERROR);
pts_storage_object::remove_in_file(PTS_CORE_STORAGE, 'openbenchmarking');
} else {
$openbenchmarking_payload = array('user_name' => $json['openbenchmarking']['account']['user_name'], 'communication_id' => $json['openbenchmarking']['account']['communication_id'], 'sav' => $json['openbenchmarking']['account']['sav']);
pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'openbenchmarking', $openbenchmarking_payload);
echo PHP_EOL . PHP_EOL . 'The Account Has Been Setup.' . PHP_EOL . PHP_EOL;
}
}
示例4: run
public static function run($r)
{
if (pts_openbenchmarking_client::user_name() == false) {
echo PHP_EOL . 'You must first be logged into an OpenBenchmarking.org account.' . PHP_EOL;
echo PHP_EOL . 'Create An Account: http://openbenchmarking.org/';
echo PHP_EOL . 'Log-In Command: phoronix-test-suite openbenchmarking-setup' . PHP_EOL . PHP_EOL;
return false;
}
if (($test_suite = pts_types::identifier_to_object($r[0])) != false) {
pts_client::$display->generic_heading($r[0]);
if (pts_validation::validate_test_suite($test_suite)) {
$zip_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . $test_suite->get_identifier(false) . '-' . $test_suite->get_version() . '.zip';
$zip_created = pts_compression::zip_archive_create($zip_file, $test_suite->xml_parser->getFileLocation());
if ($zip_created == false) {
echo PHP_EOL . 'Failed to create zip file.' . PHP_EOL;
return false;
}
$zip = new ZipArchive();
$zip->open($zip_file);
$zip->renameName(basename($test_suite->xml_parser->getFileLocation()), 'suite-definition.xml');
$zip->close();
$commit_description = pts_user_io::prompt_user_input('Enter a test commit description', false);
echo PHP_EOL;
$server_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_suite', array('ts_identifier' => $test_suite->get_identifier_base_name(), 'ts_sha1' => sha1_file($zip_file), 'ts_zip' => base64_encode(file_get_contents($zip_file)), 'ts_zip_name' => basename($zip_file), 'commit_description' => $commit_description));
echo PHP_EOL;
$json = json_decode($server_response, true);
if (isset($json['openbenchmarking']['upload']['error']) && !empty($json['openbenchmarking']['upload']['error'])) {
echo 'ERROR: ' . $json['openbenchmarking']['upload']['error'] . PHP_EOL;
}
if (isset($json['openbenchmarking']['upload']['id']) && !empty($json['openbenchmarking']['upload']['id'])) {
echo 'Command: phoronix-test-suite benchmark ' . $json['openbenchmarking']['upload']['id'] . PHP_EOL;
}
if (isset($json['openbenchmarking']['upload']['url']) && !empty($json['openbenchmarking']['upload']['url'])) {
pts_openbenchmarking::refresh_repository_lists(null, true);
echo 'URL: ' . $json['openbenchmarking']['upload']['url'] . PHP_EOL;
}
echo PHP_EOL;
unlink($zip_file);
}
}
}
示例5: run
public static function run($r)
{
$compare_tests = array();
$compare_subsystems = array();
foreach ($r as $test_object) {
$test_object = pts_types::identifier_to_object($test_object);
if ($test_object instanceof pts_test_profile) {
array_push($compare_tests, $test_object->get_identifier(false));
if (!isset($compare_subsystems[$test_object->get_test_hardware_type()])) {
$compare_subsystems[$test_object->get_test_hardware_type()] = 1;
} else {
$compare_subsystems[$test_object->get_test_hardware_type()] += 1;
}
}
}
if (empty($compare_tests)) {
$subsystem_under_test = pts_user_io::prompt_text_menu('Sub-System To Test', array('Processor', 'Graphics', 'Disk'));
} else {
arsort($compare_subsystems);
$compare_subsystems = array_keys($compare_subsystems);
$subsystem_under_test = array_shift($compare_subsystems);
}
$system_info = array_merge(phodevi::system_hardware(false), phodevi::system_software(false));
$to_include = array();
$to_exclude = array();
if (isset($system_info[$subsystem_under_test])) {
$compare_component = $system_info[$subsystem_under_test];
} else {
return;
}
switch ($subsystem_under_test) {
case 'Processor':
self::system_component_to_format($system_info, $to_include, array('OS', 'Compiler', 'Kernel', 'Motherboard'), true);
break;
case 'Graphics':
self::system_component_to_format($system_info, $to_include, array('OS', 'Display Driver', 'OpenGL', 'Processor', 'Kernel', 'Desktop'), true);
break;
case 'OS':
self::system_component_to_format($system_info, $to_include, array('Processor', 'Motherboard', 'Graphics', 'Disk'), true);
self::system_component_to_format($system_info, $to_exclude, array('OS'));
break;
case 'Disk':
self::system_component_to_format($system_info, $to_include, array('Processor', 'OS', 'Chipset', 'Motherboard', 'Kernel'), true);
break;
}
$payload = array('subsystem_under_test' => $subsystem_under_test, 'component_under_test' => $compare_component, 'include_components' => implode(',', $to_include), 'exclude_components' => implode(',', $to_exclude), 'include_tests' => implode(',', $compare_tests));
echo PHP_EOL . 'Querying test data from OpenBenchmarking.org...' . PHP_EOL;
$json = pts_openbenchmarking::make_openbenchmarking_request('auto_generate_comparison', $payload);
$json = json_decode($json, true);
if (isset($json['auto_compare']['public_ids']) && isset($json['auto_compare']['count']) && $json['auto_compare']['count'] > 0) {
echo 'Found ' . $json['auto_compare']['count'] . ' comparable results on OpenBenchmarking.org with a ' . $json['auto_compare']['accuracy'] . '% accuracy.' . PHP_EOL;
$compare_results = array();
foreach ($json['auto_compare']['public_ids'] as $public_id) {
$result_xml = pts_openbenchmarking::clone_openbenchmarking_result($public_id, true);
if ($result_xml) {
$result_file = new pts_result_file($result_xml);
$result_objects = $result_file->get_result_objects();
foreach ($result_objects as $i => &$result_object) {
if (!empty($compare_tests)) {
if (!in_array($result_object->test_profile->get_identifier(false), $compare_tests)) {
unset($result_objects[$i]);
}
} else {
if ($result_object->test_profile->get_test_hardware_type() != $subsystem_under_test) {
unset($result_objects[$i]);
}
}
}
if (count($result_objects) == 0) {
continue;
}
$result_file->override_result_objects($result_objects);
array_push($compare_results, $result_file);
}
}
if (count($compare_results) > 0) {
$result_xml = pts_merge::merge_test_results_array($compare_results);
if (count($compare_results) > 2) {
$result_file = new pts_result_file($result_xml);
$result_objects = $result_file->get_result_objects();
$system_count = $result_file->get_system_count();
$result_count = count($result_objects);
$result_match_count = array();
if ($result_count > 3) {
foreach ($result_objects as $i => &$result_object) {
$result_match_count[$i] = $result_object->test_result_buffer->get_count();
}
arsort($result_match_count);
$biggest_size = pts_arrays::first_element($result_match_count);
if ($biggest_size == $system_count || $biggest_size > 3) {
foreach ($result_match_count as $key => $value) {
if ($value < 2) {
unset($result_objects[$key]);
}
}
}
$result_file->override_result_objects($result_objects);
$result_xml = pts_merge::merge_test_results_array(array($result_file));
}
}
//.........这里部分代码省略.........
示例6: retrieve_gsid
public static function retrieve_gsid()
{
if (!pts_network::internet_support_available()) {
return false;
}
// If the GSID_E and GSID_P are not known due to being from an old client
$json = pts_openbenchmarking::make_openbenchmarking_request('retrieve_gsid', array());
$json = json_decode($json, true);
return isset($json['openbenchmarking']['gsid']) ? $json['openbenchmarking']['gsid'] : false;
}
示例7: download_test_suite
public static function download_test_suite($qualified_identifier)
{
if (is_file(PTS_TEST_SUITE_PATH . $qualified_identifier . '/suite-definition.xml')) {
return true;
}
$file = PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip';
if (pts_network::internet_support_available()) {
$hash_json = pts_openbenchmarking::make_openbenchmarking_request('suite_hash', array('i' => $qualified_identifier));
$hash_json = json_decode($hash_json, true);
$hash_check = isset($hash_json['openbenchmarking']['suite']['hash']) ? $hash_json['openbenchmarking']['suite']['hash'] : null;
// should also check for ['openbenchmarking']['suite']['error'] problems
}
if (!is_file($file)) {
if (pts_network::internet_support_available()) {
$test_suite = pts_openbenchmarking::make_openbenchmarking_request('download_suite', array('i' => $qualified_identifier));
if ($test_suite != null && ($hash_check == null || $hash_check == sha1($test_suite))) {
// save it
file_put_contents($file, $test_suite);
$hash_check = null;
} else {
if (is_file('/var/cache/phoronix-test-suite/openbenchmarking.org/' . $qualified_identifier . '.zip') && ($hash_check == null || sha1_file('/var/cache/phoronix-test-suite/openbenchmarking.org/' . $qualified_identifier . '.zip') == $hash_check)) {
copy('/var/cache/phoronix-test-suite/openbenchmarking.org/' . $qualified_identifier . '.zip', $file);
}
}
}
if (!is_file($file) && ($test_suite = self::phoromatic_server_ob_cache_request('suite', substr($qualified_identifier, 0, strpos($qualified_identifier, '/')), substr($qualified_identifier, strpos($qualified_identifier, '/') + 1)))) {
if ($b64 = base64_decode($test_suite)) {
$test_suite = $b64;
}
file_put_contents($file, $test_suite);
}
if (PTS_IS_CLIENT && !is_file($file)) {
trigger_error('Network support is needed to obtain ' . $qualified_identifier . ' data.' . PHP_EOL, E_USER_ERROR);
return false;
}
}
if (!is_file(PTS_TEST_SUITE_PATH . $qualified_identifier . '/suite-definition.xml') && is_file($file) && ($hash_check == null || is_file($file) && sha1_file($file) == $hash_check)) {
// extract it
pts_file_io::mkdir(PTS_TEST_SUITE_PATH . dirname($qualified_identifier));
pts_file_io::mkdir(PTS_TEST_SUITE_PATH . $qualified_identifier);
pts_compression::zip_archive_extract($file, PTS_TEST_SUITE_PATH . $qualified_identifier);
if (is_file(PTS_TEST_SUITE_PATH . $qualified_identifier . '/suite-definition.xml')) {
return true;
} else {
unlink($file);
return false;
}
}
return false;
}
示例8: run
public static function run($r)
{
if (pts_openbenchmarking_client::user_name() == false) {
echo PHP_EOL . 'You must first be logged into an OpenBenchmarking.org account.' . PHP_EOL;
echo PHP_EOL . 'Create An Account: http://openbenchmarking.org/';
echo PHP_EOL . 'Log-In Command: phoronix-test-suite openbenchmarking-setup' . PHP_EOL . PHP_EOL;
return false;
}
ini_set('memory_limit', '2048M');
foreach (pts_types::identifiers_to_test_profile_objects($r, false, true) as $test_profile) {
$qualified_identifier = $test_profile->get_identifier();
// First make sure the test profile is already in the OpenBenchmarking.org database...
$json = pts_openbenchmarking::make_openbenchmarking_request('is_test_profile', array('i' => $qualified_identifier));
$json = json_decode($json, true);
if (!isset($json['openbenchmarking']['test']['valid']) || $json['openbenchmarking']['test']['valid'] != 'TRUE') {
echo PHP_EOL . $qualified_identifier . ' must first be uploaded to OpenBenchmarking.org.' . PHP_EOL;
// break;
}
// Set some other things...
pts_client::pts_set_environment_variable('FORCE_TIMES_TO_RUN', 1);
pts_client::pts_set_environment_variable('TEST_RESULTS_NAME', $test_profile->get_title() . ' Testing ' . date('Y-m-d'));
pts_client::pts_set_environment_variable('TEST_RESULTS_IDENTIFIER', 'Sample Run');
pts_client::pts_set_environment_variable('TEST_RESULTS_DESCRIPTION', 1);
pts_openbenchmarking_client::override_client_setting('AutoUploadResults', true);
pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', true);
// Take screenshots
pts_client::pts_set_environment_variable('SCREENSHOT_INTERVAL', 9);
pts_module_manager::attach_module('timed_screenshot');
$force_ss = true;
$reference_ss_file = pts_module_manager::module_call('timed_screenshot', 'take_screenshot', $force_ss);
sleep(2);
$apitrace = pts_file_io::glob('/usr/local/lib/*/apitrace/wrappers/glxtrace.so');
if (!empty($apitrace) && pts_client::executable_in_path('apitrace')) {
$apitrace = array_shift($apitrace);
putenv('LD_PRELOAD=' . $apitrace);
} else {
$apitrace = false;
}
// So for any compiling tasks they will try to use the most aggressive instructions possible
putenv('CFLAGS=-march=native -O3');
putenv('CXXFLAGS=-march=native -O3');
pts_test_installer::standard_install($qualified_identifier, true);
$run_manager = new pts_test_run_manager(false, 2);
$run_manager->standard_run($qualified_identifier);
if ($apitrace) {
putenv('LD_PRELOAD=');
}
if ($reference_ss_file) {
$reference_ss = pts_image::image_file_to_gd($reference_ss_file);
unlink($reference_ss_file);
$screenshots_gd = array();
$screenshots = pts_module_manager::module_call('timed_screenshot', 'get_screenshots');
var_dump($screenshots);
foreach ($screenshots as $ss_file) {
$screenshots_gd[$ss_file] = pts_image::image_file_to_gd($ss_file);
if ($screenshots_gd[$ss_file] == false) {
continue;
}
$ss_delta = pts_image::gd_image_delta_composite($reference_ss, $screenshots_gd[$ss_file], true);
if (count($ss_delta) < floor(imagesx($reference_ss) * 0.5600000000000001) || filesize($ss_file) > 2097152) {
// If less than 56% of the pixels are changing on X, then likely not much to show off... (CLI only likely)
// Or if filesize of image is beyond 2MB
//echo 'dropping' . $ss_file . PHP_EOL;
unset($screenshots_gd[$ss_file]);
pts_file_io::unlink($ss_file);
}
}
$ss_files = array_keys($screenshots_gd);
shuffle($ss_files);
// Don't upload more than 4MB worth of screenshots
while (pts_file_io::array_filesize($ss_files) > 1048576 * 2) {
$f = array_pop($ss_files);
unlink($f);
}
if (count($ss_files) > 0) {
$c = 1;
foreach ($ss_files as $i => $file) {
$new_file = dirname($file) . '/screenshot-' . $c . '.png';
rename($file, $new_file);
$ss_files[$i] = $new_file;
$c++;
}
$ss_zip_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . 'screenshots-' . $test_profile->get_identifier_base_name() . '-' . $test_profile->get_test_profile_version() . '.zip';
$zip_created = pts_compression::zip_archive_create($ss_zip_file, $ss_files);
if ($zip_created) {
echo count($ss_files) . ' screenshots captured for use.';
//'tp_sha1' => sha1_file($zip_file),
//'tp_zip' => base64_encode(file_get_contents($zip_file)),
}
foreach ($ss_files as $file) {
// pts_file_io::unlink($file);
}
}
}
$test_binary = self::locate_test_profile_lead_binary($test_profile);
$shared_library_dependencies = array();
$instruction_usage = array();
$gl_calls = null;
if (is_executable($test_binary)) {
if ($apitrace) {
//.........这里部分代码省略.........
示例9: make_server_request
protected static function make_server_request($to_post = array())
{
static $last_communication_minute = null;
static $communication_attempts = 0;
if ($last_communication_minute == date('i') && $communication_attempts > 3) {
// Something is wrong, Phoromatic shouldn't be communicating with server more than four times a minute
return false;
} else {
if (date('i') != $last_communication_minute) {
$last_communication_minute = date('i');
$communication_attempts = 0;
}
$communication_attempts++;
}
return pts_openbenchmarking::make_openbenchmarking_request('ekofisk', $to_post);
}