Nodes/ComfyDL/Timer (Benchmark)
ComfyUI Node

Timer (Benchmark)

Is the GPU actually faster? This node settles the argument with a stopwatch

By Cynthia-lxx·Created 2 months ago·Updated 2 days ago· 6
Timer (Benchmark)
  • tensor
  • report
  • avg_seconds
operationsum
num_iters10

Every deep learning course eventually has the moment where someone asks "is the GPU actually making this faster?" and the honest answer requires a stopwatch. Timer (Benchmark) is that stopwatch as a node. Feed it any cdlTensor, pick one of five operations, and it runs the operation num_iters times, then reports total time and average seconds per iteration. It's the educational answer to "trust me, CUDA is faster" - now you can measure it yourself.

The timing is done properly, which matters more than you'd think. It runs a three-iteration warm-up first, so lazy initialization and caches don't poison your numbers. If the tensor is on CUDA, it calls torch.cuda.synchronize() before and after the timed loop - without that, the kernel launches are asynchronous and your "time" is just the queueing time, not the compute time. That's the classic benchmark mistake, and this node just doesn't make it. People building their own timing scripts get this wrong constantly; you get it for free.

Inputs

  • tensor - any cdlTensor. This is what determines whether the benchmark runs on CPU or GPU, so it's the most important input.
  • operation - dropdown: sum, mean, abs, sqrt, or neg. Just the five elementwise/reduction ops the pack defines; enough to compare memory-bound vs compute-bound behavior, not a general profiler.
  • num_iters - how many timed repetitions, default 10 (up to 100,000). Bump it for tiny tensors where a single op is sub-microsecond and noise dominates.

Outputs

Two of them, and they're a nice teaching pair:

  • report - a STRING like sqrt: 100 iters, total 0.0123 s, avg 0.000123 s/it. Human-readable, ready to show someone.
  • avg_seconds - the same average as a FLOAT, so you can wire it into another node and compare runs programmatically, or feed it to a plot.

Installing it

Part of ComfyDL. ComfyUI Manager, search "ComfyDL". Or:

cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ./ComfyDL/requirements.txt

Restart ComfyUI. The pack's only dependency is matplotlib, so install is painless - no model downloads.

Gotchas

The obvious experiment - make a tensor, run sum on a CPU tensor, then on a CUDA tensor, compare avg_seconds - is exactly what this node is for, and it usually produces the "oh, the GPU is only faster past a certain size" lesson that every ML course wants you to have. The trap to avoid is the opposite one: don't benchmark a tiny tensor on GPU and conclude GPUs are slow. Small kernels have launch overhead that dwarfs the compute; the crossover point is the interesting number.

A practical note for the report output: it's a STRING, and in this pack strings flow to text/display nodes just fine. Also, since ComfyUI caches aggressively, a Timer node wired into a static tensor will run once and then sit on its cached result - if you're timing a tensor that changes every run, that's fine; if you're timing a static one, the first run is the one that counts. This is a niche educational pack with almost no community chatter, but the timing logic here is textbook-correct, so you can trust the numbers it gives you.

Categoryutilities

Inputs (3)

NameTypeDefaultDescription
tensorTENSOR
operationCOMBOsum5 options: sum, mean, abs, sqrt, neg
num_itersINT101–100000

Outputs (2)

NameTypeDescription
reportSTRING
avg_secondsFLOAT