diff --git a/lib/Projectrans/Phase2Translator.py b/lib/Projectrans/Phase2Translator.py index 44f2b9e..778bdfe 100644 --- a/lib/Projectrans/Phase2Translator.py +++ b/lib/Projectrans/Phase2Translator.py @@ -2091,14 +2091,23 @@ class Phase2Translator: n_workers = _PickWorkerCount(len(need_compile), 400) _vlog().info(f" 并行编译 {len(need_compile)} 个文件 (workers={n_workers})") errors = [] + _compile_total = len(need_compile) + _compile_done = 0 with ThreadPoolExecutor(max_workers=n_workers) as executor: - futures = {executor.submit(_compile_one, ll_path): ll_path for ll_path in need_compile} + futures = {} + for ll_path in need_compile: + futures[executor.submit(_compile_one, ll_path)] = (ll_path, time.time()) for future in as_completed(futures): + ll_path, _t_sub = futures[future] rel, status, err = future.result() + _compile_done += 1 + _elapsed_c = time.time() - _t_sub + _sha1_c = os.path.basename(ll_path)[:-3] + _src_c = self.sha1_map.get(_sha1_c, '?') if status == 'ok': - _vlog().success(f" {rel}") + _vlog().success(f" [{_compile_done}/{_compile_total}] {os.path.basename(ll_path)} {_src_c} ({_elapsed_c:.1f}s)") elif status == 'error': - _vlog().error(f" {rel}: {err}") + _vlog().error(f" [{_compile_done}/{_compile_total}] {rel}: {err}") errors.append((rel, err)) elif status == 'cached': pass