time while [ $VAR -lt 1000000 ]
This command completed in about 17.5 seconds on both the Xfce terminal emulator and on xterm. If you wish to run it a second time, don't forget to reset VAR back to 0. The second test consisted of a C program (which I call "count.c") that basically does the same thing:
#define MAX_COUNT 1000000
int counter = 0;
while(counter < MAX_COUNT)
To compile this program on Linux/BSD: gcc count.c -o count
Execute it with the "time" command preceeding it:
This is where it gets a little interesting. While both the Xfce terminal emulator and xterm ran the while loop in about the same amount of time, xterm was over twice as fast running the C version than the Xfce terminal emulator. The Xfce terminal emulator took about 17.5 seconds to execute it, whereas xterm only took 8.5 seconds. I ran it on both several times to make sure. Strange, but not the crux of the issue described in this post's title. After getting some benchmarks running in terminal emulators under X, I wanted to see what it would do running on the Linux frame buffer console. To accomplish this, I switched to a virtual terminal (Ctrl-Alt-F2), and executed both the while loop, and the C program.
The difference was nothing short of astounding! I had hoped the times would be lower, but the reverse is true, and not just by a little bit either! The while loop took a whopping two minutes and four seconds to complete, and the C program took around 1 minute. That is one heck of a difference! After forcing my bottom jaw back up, I turned to my OpenBSD computer and tried it on the console first, and the times were better than Linux: around one minute for the while loop, and 34 seconds for the C program. Running the while loop and C program in terminal emulators under X (Xfce terminal emulator and xterm again): The while loop took right at one minute under Xfce terminal emulator, and a whopping five minutes in xterm!!! what's up with that, huh? The C program took only 34.5 seconds on the Xfce terminal emulator, and over five minutes on xterm. I'm really not sure why it takes so long on xterm under OpenBSD though.
Sorry about the ramble, I just thought it was a neat article, and testing this on my computers gave me a much better appreciation for the project. I will most definitely want to try kmscon out on my computers, simply because I spend a lot of time on the Linux console.