uranusjr commented on code in PR #33626:
URL: https://github.com/apache/airflow/pull/33626#discussion_r1302424367


##########
dev/perf/scheduler_dag_execution_timing.py:
##########
@@ -297,35 +296,30 @@ def main(num_runs, repeat, pre_create_dag_runs, 
executor_class, dag_ids):
     code_to_test = lambda: run_job(job=job_runner.job, 
execute_callable=job_runner._execute)
 
     for count in range(repeat):
-        gc.disable()
-        start = time.perf_counter()
-
-        code_to_test()
-        times.append(time.perf_counter() - start)
-        gc.enable()
-        print("Run %d time: %.5f" % (count + 1, times[-1]))
-
-        if count + 1 != repeat:
+        if not count:
             with db.create_session() as session:
                 for dag in dags:
                     reset_dag(dag, session)
-
             executor.reset(dag_ids)
             scheduler_job = Job(executor=executor)
             job_runner = SchedulerJobRunner(job=scheduler_job, 
dag_ids=dag_ids, do_pickle=False)
             executor.scheduler_job = scheduler_job
 
+        gc.disable()
+        start = time.perf_counter()
+        code_to_test()
+        times.append(time.perf_counter() - start)
+        gc.enable()
+        print(f"Run {count + 1} time: {times[-1]:.5f}")
+
     print()
     print()
-    msg = "Time for %d dag runs of %d dags with %d total tasks: %.4fs"
-
+    msg = f"Time for {num_runs} dag runs of {len(dags)} dags with 
{total_tasks} total tasks: "
     if len(times) > 1:
-        print(
-            (msg + " (±%.3fs)")
-            % (num_runs, len(dags), total_tasks, statistics.mean(times), 
statistics.stdev(times))
-        )
+        msg += f"{statistics.mean(times):.4f}s 
(±{statistics.stdev(times):.3f}s)"
     else:
-        print(msg % (num_runs, len(dags), total_tasks, times[0]))
+        msg += f"{times[0]:.4f}s"
+    print(msg)

Review Comment:
   Might be easier to do
   
   ```python
   print(f"Time for ...", end="")
   if len(times) > 1:
       print(f"...")
   else:
       print(f"...")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to