1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-05 12:21:02 +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:
epriestley 2011-05-20 21:15:00 -07:00
parent 1efc66a0dd
commit d202e71ef1
4 changed files with 37 additions and 6 deletions

View file

@ -29,14 +29,19 @@ class DarkConsoleServicesPlugin extends DarkConsolePlugin {
} }
public function generateData() { public function generateData() {
return PhutilServiceProfiler::getInstance()->getServiceCallLog();
return array(
'start' => $GLOBALS['__start__'],
'log' => PhutilServiceProfiler::getInstance()->getServiceCallLog(),
);
} }
public function render() { public function render() {
$data = $this->getData(); $data = $this->getData();
$log = $data['log'];
$rows = array(); $rows = array();
foreach ($data as $row) { foreach ($log as $row) {
switch ($row['type']) { switch ($row['type']) {
case 'query': case 'query':
@ -62,6 +67,7 @@ class DarkConsoleServicesPlugin extends DarkConsolePlugin {
$rows[] = array( $rows[] = array(
phutil_escape_html($row['type']), phutil_escape_html($row['type']),
'+'.number_format(1000 * ($row['begin'] - $data['start'])).' ms',
number_format(1000000 * $row['duration']).' us', number_format(1000000 * $row['duration']).' us',
$info, $info,
); );
@ -72,11 +78,13 @@ class DarkConsoleServicesPlugin extends DarkConsolePlugin {
array( array(
null, null,
'n', 'n',
'n',
'wide wrap', 'wide wrap',
)); ));
$table->setHeaders( $table->setHeaders(
array( array(
'Event', 'Event',
'Start',
'Duration', 'Duration',
'Details', 'Details',
)); ));

View file

@ -435,8 +435,26 @@ class DifferentialChangesetParser {
$this->oldRender = explode("\n", phutil_escape_html($old_corpus_block)); $this->oldRender = explode("\n", phutil_escape_html($old_corpus_block));
$this->newRender = explode("\n", phutil_escape_html($new_corpus_block)); $this->newRender = explode("\n", phutil_escape_html($new_corpus_block));
} else { } else {
$this->oldRender = $this->sourceHighlight($this->old, $old_corpus_block); $old_future = $this->getHighlightFuture($old_corpus_block);
$this->newRender = $this->sourceHighlight($this->new, $new_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( $this->applyIntraline(
@ -648,10 +666,13 @@ class DifferentialChangesetParser {
} }
} }
protected function sourceHighlight($data, $corpus) { protected function getHighlightFuture($corpus) {
$result = $this->highlightEngine->highlightSource( return $this->highlightEngine->getHighlightFuture(
$this->filetype, $this->filetype,
$corpus); $corpus);
}
protected function processHighlightedSource($data, $result) {
$result_lines = explode("\n", $result); $result_lines = explode("\n", $result);
foreach ($data as $key => $info) { foreach ($data as $key => $info) {

View file

@ -20,6 +20,7 @@ phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phutil', 'filesystem'); phutil_require_module('phutil', 'filesystem');
phutil_require_module('phutil', 'filesystem/tempfile'); phutil_require_module('phutil', 'filesystem/tempfile');
phutil_require_module('phutil', 'future');
phutil_require_module('phutil', 'future/exec'); phutil_require_module('phutil', 'future/exec');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'markup/syntax/engine/default'); phutil_require_module('phutil', 'markup/syntax/engine/default');

View file

@ -16,6 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
$__start__ = microtime(true);
error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
ini_set('memory_limit', -1); ini_set('memory_limit', -1);