mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-03 11:21:01 +01:00
Use parallel syntax highlighting API in differential
Summary: Use the new API from D322 to highlight text in parallel in Differential. Test Plan: Verified that pygemntize calls started within 20ms of one another in DarkConsole (also: added a feature to let me do this) instead of running serially. Reviewed By: aran Reviewers: jungejason, tuomaspelkonen, aran CC: aran Differential Revision: 323
This commit is contained in:
parent
1efc66a0dd
commit
d202e71ef1
4 changed files with 37 additions and 6 deletions
|
@ -29,14 +29,19 @@ class DarkConsoleServicesPlugin extends DarkConsolePlugin {
|
|||
}
|
||||
|
||||
public function generateData() {
|
||||
return PhutilServiceProfiler::getInstance()->getServiceCallLog();
|
||||
|
||||
return array(
|
||||
'start' => $GLOBALS['__start__'],
|
||||
'log' => PhutilServiceProfiler::getInstance()->getServiceCallLog(),
|
||||
);
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$data = $this->getData();
|
||||
$log = $data['log'];
|
||||
|
||||
$rows = array();
|
||||
foreach ($data as $row) {
|
||||
foreach ($log as $row) {
|
||||
|
||||
switch ($row['type']) {
|
||||
case 'query':
|
||||
|
@ -62,6 +67,7 @@ class DarkConsoleServicesPlugin extends DarkConsolePlugin {
|
|||
|
||||
$rows[] = array(
|
||||
phutil_escape_html($row['type']),
|
||||
'+'.number_format(1000 * ($row['begin'] - $data['start'])).' ms',
|
||||
number_format(1000000 * $row['duration']).' us',
|
||||
$info,
|
||||
);
|
||||
|
@ -72,11 +78,13 @@ class DarkConsoleServicesPlugin extends DarkConsolePlugin {
|
|||
array(
|
||||
null,
|
||||
'n',
|
||||
'n',
|
||||
'wide wrap',
|
||||
));
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'Event',
|
||||
'Start',
|
||||
'Duration',
|
||||
'Details',
|
||||
));
|
||||
|
|
|
@ -435,8 +435,26 @@ class DifferentialChangesetParser {
|
|||
$this->oldRender = explode("\n", phutil_escape_html($old_corpus_block));
|
||||
$this->newRender = explode("\n", phutil_escape_html($new_corpus_block));
|
||||
} else {
|
||||
$this->oldRender = $this->sourceHighlight($this->old, $old_corpus_block);
|
||||
$this->newRender = $this->sourceHighlight($this->new, $new_corpus_block);
|
||||
$old_future = $this->getHighlightFuture($old_corpus_block);
|
||||
$new_future = $this->getHighlightFuture($new_corpus_block);
|
||||
$futures = array(
|
||||
'old' => $old_future,
|
||||
'new' => $new_future,
|
||||
);
|
||||
foreach (Futures($futures) as $key => $future) {
|
||||
switch ($key) {
|
||||
case 'old':
|
||||
$this->oldRender = $this->processHighlightedSource(
|
||||
$this->old,
|
||||
$future->resolve());
|
||||
break;
|
||||
case 'new':
|
||||
$this->newRender = $this->processHighlightedSource(
|
||||
$this->new,
|
||||
$future->resolve());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->applyIntraline(
|
||||
|
@ -648,10 +666,13 @@ class DifferentialChangesetParser {
|
|||
}
|
||||
}
|
||||
|
||||
protected function sourceHighlight($data, $corpus) {
|
||||
$result = $this->highlightEngine->highlightSource(
|
||||
protected function getHighlightFuture($corpus) {
|
||||
return $this->highlightEngine->getHighlightFuture(
|
||||
$this->filetype,
|
||||
$corpus);
|
||||
}
|
||||
|
||||
protected function processHighlightedSource($data, $result) {
|
||||
|
||||
$result_lines = explode("\n", $result);
|
||||
foreach ($data as $key => $info) {
|
||||
|
|
|
@ -20,6 +20,7 @@ phutil_require_module('phabricator', 'storage/queryfx');
|
|||
|
||||
phutil_require_module('phutil', 'filesystem');
|
||||
phutil_require_module('phutil', 'filesystem/tempfile');
|
||||
phutil_require_module('phutil', 'future');
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'markup/syntax/engine/default');
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$__start__ = microtime(true);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
ini_set('memory_limit', -1);
|
||||
|
|
Loading…
Reference in a new issue