Skip to content

Instantly share code, notes, and snippets.

@msonnabaum
Created December 14, 2012 19:32
Show Gist options
  • Save msonnabaum/4287963 to your computer and use it in GitHub Desktop.
Save msonnabaum/4287963 to your computer and use it in GitHub Desktop.
<?php
function changed_functions() {
return array(
'field_invoke_method',
'field_invoke_method_multiple',
'_field_invoke',
'_field_invoke_multiple',
'field_attach_preprocess',
'field_info_extra_fields',
'field_info_max_weight',
'field_info_field_settings',
'field_info_instance_settings',
'field_info_widget_settings',
'field_info_formatter_settings',
'field_view_field',
'process_entity'
);
}
$noternary_files = array_map(function($file) {
return "/tmp/noternary/$file";
}, scandir('/tmp/noternary'));
$ternary_files = array_map(function($file) {
return "/tmp/ternary/$file";
}, scandir('/tmp/ternary'));
function extract_changed_functions($xhprof_data, $label) {
$ret = array();
foreach ($xhprof_data as $key => $value) {
list($caller, $callee) = array_pad(explode('==>', $key, 2), 2, null);;
if (in_array($callee, changed_functions())) {
$value['name'] = $callee;
$value['label'] = $label;
$ret[] = $value;
}
}
return $ret;
}
function get_changed_values($files, $label) {
$ret = array();
foreach ($files as $file) {
if (strpos($file, '/.') !== FALSE) continue;
$xhprof_data = unserialize(file_get_contents($file));
$changed_values = extract_changed_functions($xhprof_data, $label);
$ret += $changed_values;
}
return $ret;
}
$ternary_values = get_changed_values($ternary_files, 'ternary');
$noternary_values = get_changed_values($noternary_files, 'noternary');
$combined = array_merge($ternary_values, $noternary_values);
print json_encode($combined);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment