Overhead cost of spawning child processes
The (non-negligible) cost is the set up of the in-kernel structures to keep track of the new process (setting up page tables and so on).
You can easily measure it: Write a small program just like the one you have:
#include &lt;unistd.h&gt;

/* Define FORK for forking version */

#ifdef FORK
#define ROUNDS 10000
#else
#define ROUNDS 10000000
#endif

int main(void)
{
        for(int i = 0; i &lt; ROUNDS; i++) {
#ifdef FORK             
                if(fork() == 0) /* Child */
                        return 0;
#endif          
        }
}

and run it under time(1). Here I get (Intel(R) Core(TM) m5-6Y57 CPU @ 1.10GHz,   Fedora 32, kernel 5.7.15-200.fc32.x86_64, gcc-10.2.1-1.fc32, no optimization; just checked that the non-forking code does it's rounds) for non-forking:
real    0m0.027s
user    0m0.024s
sys     0m0.004s

For forking:
real    0m0.436s
user    0m0.016s
sys     0m0.414s

Very definitely not advisable.