I was told someone's awk code ran almost as fast as C. Not sure that's close to a true statement even in simple tasks. I wrote two tests and ran them with Linux's time command. Is this a fair and valid test? I need to give my management an honest answer.
Note that the code runs but I have to hand transcribe it.
### C
Code:
#include <stdio.h>
int main(void)
{
FILE *fp;
fp = fopen("/dev/null", "w");
char my_string[10] = "123rte";
int i;
for ( i = 0; i < 10000; i++ )
{
fprintf(fp, "%s\n", my_string);
}
fclose(fp);
return 0;
}
### awk
Code:
#!/bin/bash
my_string="123rte"
for (( n=0; n<10000; n++)) do
echo $my_string | awk '{ print $1 }' > /dev/null 2>&1
done