Ninja vs GNU Make, Measured: the Clean Build Is a Wash — the No-Op Isn't
Switching a CMake project from GNU Make to Ninja does not make the clean build faster — at 32-way parallelism the two are within 4 percent of each other. What it does is answer 'nothing to do' in 14 milliseconds instead of 154. Same project, same compiler, medians of three runs: here are the numbers.
Written November 8, 2026 · Tested with CMake 3.28 · 10 min read
- The table
- The clean build is a wash
- The no-op is the win
- One file, one header
common.h plus <string>, <vector>, and <algorithm>, each doing real if small code generation work, and a main.cpp that calls all 200 functions. Same sources, same CMakeLists.txt, two build directories — only the generator differs.What this guide is
This guide measures what changes when a CMake project switches its generator from GNU Make to Ninja. It does not teach the switch itself. The setup lives in the companion guide on this site, C++20 Modules with CMake 3.28 and Ninja, which teaches Ninja with CMake and contains no timing content at all.
The headline is a correction, not a confirmation. The best-known comparison, the Meson project's "A simple comparison", says switching the CMake backend from Make to Ninja can "shave off 3.5 seconds (over 20%) of the total build time". With 32-way parallelism, the clean-build gap is gone. What survives, and by an order of magnitude, is the no-op check.
The numbers in this guide are the fresh ones. The 2026-11-07 figures are quoted alongside wherever they differ, and no number is carried forward without re-execution.
The setup
One generated project, deterministic from seed 20261107: 200 translation units, each including a shared common.h plus <string>, <vector>, and <algorithm>, each doing real if small code generation work, and a main.cpp that calls all 200 functions. Same sources, same CMakeLists.txt, two build directories — only the generator differs.
The toolchain: CMake 3.28.3, GNU Make 4.3, g++ 13.3.0, Ninja 1.13.2, 32 CPUs, Release build, C++17, --parallel 32 on both sides. Ninja is not installed system-wide. The probe used the standalone binary already present at the vcpkg tools path, so the Ninja configure passes the binary explicitly. On a machine with Ninja installed, a plain -G Ninja finds it.
cmake -S proj -B build-ninja -G Ninja \
-DCMAKE_MAKE_PROGRAM=/home/user/vcpkg/downloads/tools/ninja-1.13.2-linux/ninja \
-DCMAKE_BUILD_TYPE=Release
cmake --build build-ninja --parallel 32
cmake -S proj -B build-make -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build build-make --parallel 32
Each case ran three times per generator, in a fresh build directory each time: configure, clean build, no-op rebuild, rebuild after touching one source file (tu_100.cpp), rebuild after touching the shared header (common.h). Thirty timed runs in total, all with return code 0.
The table
Medians of three runs, in seconds. The ratio column is Make divided by Ninja: above 1 means Ninja was faster.
| Case | Ninja | GNU Make | Make / Ninja |
|---|---|---|---|
| Configure | 0.156 | 0.174 | 1.12x |
| Clean build | 3.437 | 3.566 | 1.04x |
| No-op rebuild | 0.014 | 0.154 | 11.0x |
| Touch one .cpp | 0.370 | 0.431 | 1.16x |
| Touch common.h | 3.414 | 3.702 | 1.08x |
The ranges behind the medians: configure, Ninja 0.155 to 0.310 seconds against Make 0.174 to 0.180; clean build, Ninja 3.374 to 4.218 against Make 2.393 to 3.665; no-op, Ninja 0.014 to 0.015 against Make 0.148 to 0.217; one file, Ninja 0.331 to 0.396 against Make 0.430 to 0.450; header touch, Ninja 3.412 to 3.418 against Make 3.686 to 3.780. The 2026-11-07 probe agrees in shape on every row: configure 0.159 against 0.185, clean 3.349 against 3.552, no-op 0.015 against 0.162, one file 0.369 against 0.442, header 3.358 against 3.642.
The clean build is a wash
Ninja 3.437 seconds, Make 3.566 seconds, a 1.04x median ratio. That is not a win; it is noise with a sign. The ranges overlap heavily: Make's fastest clean build, 2.393 seconds, beats Ninja's slowest, 4.218 seconds. At 32 cores the build is compiler-bound. Two hundred translation units compile in parallel, and the generator is not the bottleneck — the compiler is. Say "essentially identical", not "Ninja is 4 percent faster".
This does not reproduce the Meson comparison's clean-build claim, and the reason is visible in its method. That experiment ran on a 2011 MacBook Pro with four parallel jobs, a thousand trivial C files, and took the fastest time of several runs. With four jobs, the generator's scheduling and startup costs are a visible share of the total. With 32 jobs and real C++ code generation, they are not. The Meson gap was real on its hardware. It does not transfer to a 32-core box.
An independent modern benchmark points the same way. Nift Labs publishes a median-based Make-versus-Ninja benchmark on synthetic corpora, workers capped at four, invoked directly rather than through CMake. At 1,000 light translation units with four workers, its clean full build is Make 5,534 milliseconds against Ninja 6,271 milliseconds — Ninja slower, not faster. With a heavy profile at the same size, Make 14,867 milliseconds against Ninja 15,003. Two different methods, same direction: no clean-build win for Ninja once the compiler owns the clock.
The no-op is the win
Ninja 0.014 seconds, Make 0.154 seconds, an 11.0x median ratio. Ninja answers "nothing to do" in 14 milliseconds. Make takes 154 milliseconds to reach the same conclusion. This is the case a developer hits dozens of times a day: every cmake --build after a no-change edit cycle, every check whether the tree is up to date.
The mechanism is the design, not an accident. The Ninja manual states its goal as "very fast (i.e., instant) incremental builds, even for very large projects", and explains that Ninja "contains the barest functionality necessary to describe arbitrary dependency graphs" so it can "do the minimum work necessary to figure out what needs to be built immediately". For each built file Ninja keeps a log of the command used to build it, in .ninja_log, and a compacted dependency database, in .ninja_deps. A no-op is a graph load and a timestamp check. Make re-parses the Makefiles and re-stats 200 dependency files before it can say the same thing.
The 2026-11-07 probe measured the same shape: no-op 0.015 seconds against 0.162, a 10.8x median ratio. One difference between the days is worth stating. The 2026-11-07 run had first-run outliers on both sides: the Ninja no-op took 1.076 seconds on its first run, and the Make no-op took 0.730 seconds on its second. The fresh run shows no such outliers — Ninja 0.014, 0.014, 0.015 seconds; Make 0.154, 0.217, 0.148. The medians absorb the outliers either way, which is why this guide reports medians and ranges and never one run's value.
One file, one header
Touch one source file: Ninja 0.370 seconds against Make 0.431, a 1.16x ratio. One translation unit recompiles in about 0.3 seconds and the link follows; the generator overhead is a small share of the total, so the gap stays small. The 2026-11-07 probe measured 0.369 against 0.442, a 1.20x ratio.
Touch the shared header: Ninja 3.414 seconds against Make 3.702, a 1.08x ratio. Every translation unit rebuilds, because all 200 include common.h. Same compiler work, same parallelism, same wash as the clean build. The 2026-11-07 probe measured 3.358 against 3.642, the same 1.08x ratio.
The same binary, byte for byte
Both generators produce the same program. Both binaries print total=3920863397 label=tu-42, both are 370,368 bytes, and both have the same md5 checksum, 8d681e371ee103dcb21c495e62511d06. The 2026-11-07 probe produced the identical checksum and size. The generator changes nothing about the output — only the time to get there.
What this guide does not cover
The project is generated, not a real codebase. Two hundred translation units, one project shape, 32 cores, Release, g++ 13.3.0. A 4-core laptop, a Debug build, or a 10,000-translation-unit codebase will show different ratios. The no-op direction is the portable part; the exact 11.0x is not. The Nift Labs benchmark makes the same point from the other side: its direct-invocation no-op ratio at 1,000 translation units is 2.18x, not 11.0x — different method, different scale, same direction. Ratios do not transfer between setups; the direction does.
All timings go through cmake --build, which adds CMake's own build-system check to every invocation. That is the honest user-facing number, and the same wrapper on both sides, but a raw ninja against raw make invocation was not measured here. Do not quote direct-invocation numbers from this guide.
Configure is close enough to ignore: 0.156 seconds against 0.174, a 1.12x ratio on a step that runs once per build directory. It is in the table for completeness, not as a reason to switch.
Checklist
- Before switching generators for speed, check which case you actually hit: if your clean builds are slow, the generator is probably not the bottleneck at high parallelism — the compiler is.
- Before quoting a clean-build speedup, check the parallelism it was measured at: the 20 percent figure came from four jobs on a 2011 laptop, and it does not reproduce at 32 jobs.
- Before trusting one timed run, check the median and the range: the clean-build ranges here overlap, and the 2026-11-07 no-op runs had first-run outliers over a second on both sides.
- Before choosing a generator for the edit-compile cycle, check the no-op: 14 milliseconds against 154 is the gap you feel dozens of times a day, and it is the only order-of-magnitude gap in the table.
- Before claiming the outputs differ, check the checksum: both binaries here are byte-identical, md5
8d681e371ee103dcb21c495e62511d06. - Before setting up Ninja with CMake, check the companion guide: C++20 Modules with CMake 3.28 and Ninja teaches the setup, including the
-DCMAKE_MAKE_PROGRAMpath on a machine with no system Ninja.
Related guides on this site
- Fix CMake "Generator Does Not Match" and Stale-Cache Errors When Switching Ninja and Make
- Fix C++ "no match for 'operator<<'" — Streaming a User-Defined Type and a std::vector of It to std::cout
- Fix 'No Matching Function for Call' in C++ — Reading GCC's Candidate List, Viable vs Not Viable, and Conversion Failures
- Fix CMake "Cannot Find Source File" and "No SOURCES Given to Target"
Sources
- The Ninja build system — manual — design goals ("very fast (i.e., instant) incremental builds"); "do the minimum work necessary to figure out what needs to be built immediately"; the
.ninja_logcommand log and the.ninja_depscompacted dependency database; builds run in parallel by default on the number of CPUs. Read fresh 2026-11-08. - Ninja — CMake Documentation — the
Ninjagenerator writes abuild.ninjafile into the build tree. Read fresh 2026-11-08. - CMAKE_MAKE_PROGRAM — CMake 3.28 Documentation — the tool that launches the native build system; the Ninja generator sets it to
ninjaand stores it in the CMake cache;cmake --builduses it to launch the build. Read fresh 2026-11-08; matches the box CMake 3.28.3. - A simple comparison — The Meson Build System — the secondary this guide corrects: 1,000 trivial C files, 2011 MacBook Pro, Ubuntu 13.04, four parallel jobs, "ran multiple times and always took the fastest time"; CMake backend switch "shave off 3.5 seconds (over 20%) of the total build time". Read fresh 2026-11-08.
- Build Systems Benchmark — Nift Labs — the nearest modern median benchmark, opened in full 2026-11-08: GNU Make 4.4.1 against Ninja 1.13.2, synthetic corpora of 100 to 10,000 translation units, workers 1, 2, and 4, direct invocation, three-way with Nift. Clean full at 1,000 light translation units, four workers: Make 5,534 ms against Ninja 6,271 ms. Warm no-op at the same size: Make 39.545 ms against Ninja 18.152 ms. Same direction as this guide, different method and scale; the ratios are not directly comparable.
- C++20 Modules with CMake 3.28 and Ninja — the companion guide on this site: teaches the Ninja setup with CMake, including the
-DCMAKE_MAKE_PROGRAMpath on a machine with no system Ninja. It contains zero speed, timing, faster, or benchmark words; this guide links it and re-teaches none of it.
Keep Exploring
Seven tips and seven puzzles so far, each one a short runnable example with the fix explained.
Paste an AddressSanitizer, UBSan, or ThreadSanitizer report and get the bug, the file and line, and the fix \u2014 in plain language.
C++20 and C++23 features, migration paths, and measured trade-offs.
The full C++ hub \u2014 language basics, the standard library, coroutines, and measured comparisons.
Paste a [Service] section and get a plain-language verdict on every sandboxing setting it finds.