feat(extract): expose --threads to upgrade-extract + report elapsed time

emitOpenFormats now takes an optional threadCount parameter (0 =
auto). The asset_extract --upgrade-extract path forwards opts.threads
so users can override the auto-detect when running on a CI machine
with limited cores or wanting deterministic timing.

Also wraps the upgrade pass with a chrono timer and prints elapsed
seconds so the parallelization payoff is visible at a glance:

  asset_extract --upgrade-extract Data/expansions/wotlk --threads 8
  Walking Data/expansions/wotlk for open-format upgrades...
    elapsed           : 47.2 s
    PNG (BLP→PNG)     : 12340 ok
    ...

Verified end-to-end: --threads 2 on 5 hand-built DBCs converts all
5 in well under a second.
This commit is contained in:
Kelsi 2026-05-06 10:57:18 -07:00
parent cab1912441
commit 463a8cd751
3 changed files with 15 additions and 4 deletions

View file

@ -1,5 +1,6 @@
#include "extractor.hpp"
#include "open_format_emitter.hpp"
#include <chrono>
#include <filesystem>
#include <iostream>
#include <string>
@ -120,11 +121,17 @@ int main(int argc, char** argv) {
}
std::cout << "Walking " << upgradeDir
<< " for open-format upgrades...\n";
auto t0 = std::chrono::steady_clock::now();
wowee::tools::OpenFormatStats stats;
// Pass 0 to auto-detect threads (or honor user --threads override).
unsigned int t = opts.threads > 0 ? static_cast<unsigned int>(opts.threads) : 0;
wowee::tools::emitOpenFormats(upgradeDir,
opts.emitPng, opts.emitJsonDbc,
opts.emitWom, opts.emitWob,
opts.emitTerrain, stats);
opts.emitTerrain, stats, t);
auto secs = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - t0).count() / 1000.0;
std::cout << " elapsed : " << secs << " s\n";
std::cout << " PNG (BLP→PNG) : " << stats.pngOk << " ok"
<< (stats.pngFail ? ", " + std::to_string(stats.pngFail) + " failed" : "") << "\n";
std::cout << " JSON (DBC→JSON) : " << stats.jsonDbcOk << " ok"