|
45 | 45 | #include "indexer/Path.h"
|
46 | 46 | #include "indexer/RAII.h"
|
47 | 47 | #include "indexer/ScipExtras.h"
|
| 48 | +#include "indexer/Timer.h" |
48 | 49 |
|
49 | 50 | namespace boost_ip = boost::interprocess;
|
50 | 51 |
|
@@ -575,11 +576,22 @@ class Driver {
|
575 | 576 | }
|
576 | 577 |
|
577 | 578 | void run() {
|
578 |
| - auto compdbGuard = this->openCompilationDatabase(); |
579 |
| - this->spawnWorkers(compdbGuard); |
580 |
| - this->runJobsTillCompletionAndShutdownWorkers(); |
581 |
| - this->emitScipIndex(); |
582 |
| - spdlog::debug("indexing complete; driver shutting down now, kthxbai"); |
| 579 | + ManualTimer total, indexing, merging; |
| 580 | + unsigned numTus; |
| 581 | + |
| 582 | + TIME_IT(total, { |
| 583 | + auto compdbGuard = this->openCompilationDatabase(); |
| 584 | + this->spawnWorkers(compdbGuard); |
| 585 | + TIME_IT(indexing, |
| 586 | + numTus = this->runJobsTillCompletionAndShutdownWorkers()); |
| 587 | + TIME_IT(merging, this->emitScipIndex()); |
| 588 | + spdlog::debug("indexing complete; driver shutting down now, kthxbai"); |
| 589 | + }); |
| 590 | + using secs = std::chrono::seconds; |
| 591 | + fmt::print("Finished indexing {} translation units in {:.1f}s (indexing: " |
| 592 | + "{:.1f}s, merging: {:.1f}s).\n", |
| 593 | + numTus, total.value<secs>(), indexing.value<secs>(), |
| 594 | + merging.value<secs>()); |
583 | 595 | }
|
584 | 596 |
|
585 | 597 | private:
|
@@ -710,15 +722,21 @@ class Driver {
|
710 | 722 | return commands.size();
|
711 | 723 | }
|
712 | 724 |
|
713 |
| - void runJobsTillCompletionAndShutdownWorkers() { |
| 725 | + /// Returns the number of TUs processed |
| 726 | + unsigned runJobsTillCompletionAndShutdownWorkers() { |
| 727 | + unsigned numJobs = 0; |
714 | 728 | this->scheduler.runJobsTillCompletion(
|
715 |
| - [this]() -> void { this->processOneJobResult(); }, |
| 729 | + [this, &numJobs]() -> void { |
| 730 | + this->processOneJobResult(); |
| 731 | + numJobs++; |
| 732 | + }, |
716 | 733 | [this]() -> size_t { return this->refillJobs(); },
|
717 | 734 | [this](ToBeScheduledWorkerId &&workerId, JobId jobId) -> void {
|
718 | 735 | this->assignJobToWorker(std::move(workerId), jobId);
|
719 | 736 | });
|
720 | 737 | this->shutdownAllWorkers();
|
721 | 738 | this->scheduler.waitForAllWorkers();
|
| 739 | + return numJobs / 2; // Each TU has exactly 2 jobs. |
722 | 740 | }
|
723 | 741 |
|
724 | 742 | FileGuard openCompilationDatabase() {
|
|
0 commit comments