You donโt have to use an IDE to do C programming. There is Digital Mars C as an example of that. We have talked about the Xcode command line tools before, that frees the gcc compiler to (also) be a command line tool to write C programs from the command line separate to any IDE usage.
So it is today with this tutorial, where we work with Digital Mars C, to time some inhouse and C string library (string.h) library string manipulation functionality. If you get to compile (recommend Digital Mars C) and run this tutorialโs download at a Windows Command Line (prompt) you will see how fast C is, working way down there near the kernel level. So the second accuracy of time(NULL) wonโt pass muster for the timings, and instead, here, we use the clock() functionality to get the refinement required to have it mean anything. Could be affected by so many other things anyway, like what else is running, but is instructive as to what you might have thought was the fastest method. Personally, love using strstr() to find strings within strings, but, as you can see from the numbers, there are better choices such as strchr() and strpbrk() โฆ personally, Iโm affronted, gobsmacked, insulted, resigned โฆ impersonally, Iโm anti-affronted, anti-gobsmacked, anti-insulted, anti-resigned โฆ the nearby ants, antily-anti-affronted, antily-anti-gobsmacked, antily-anti-insulted, antily-anti-resigned.
So feel free to download the C programming source code here and rename it to timingsc
Hope you enjoy this tutorial showing you some command line C dmc (Digital Mars) compilation work.
A really helpful tutorial for code above to do with using clock() is shown here โฆ thanks.
A really helpful tutorial for C string functionality via string.h is shown here โฆ thanks.
If this was interesting you may be interested in this too.
One Response to C String Function Timings Primer Tutorial