I was looking through a bunch of archived Lounge topics from 2010, and I found this one, which I thought was kind of interesting. I pasted the code into TextMate, saved it, and it compiled just fine when I linked with -lncurses.
My best time was 0:07:35. But then I don't do a lot of typing other than C++, which only requires random words and weird punctuation. I could probably write an entire Hello World program in about 10 seconds...
I know this is going to turn into just people posting their times (and people who get 0:00:25 times because they cheat and paste the alphabet in), but it was interesting digging this up.
Running it on cpp.sh always gives 0:00.00 as the output.
Once I ran it on VS I got an ok time on my first try:
It took you 0:04.96. Good job!
However, there's something wrong with the program. What I thought would be my best time ended up being:
It took you 0:10.60. Good job!
It took me a few seconds to start typing, and it seems to have counted them. A little testing showed that about 3 out of 5 times, the timer starts as soon as the program runs.
Anyway, this was the best time I got after about 10 minutes of tinkering around with the program:
Running it on cpp.sh always gives 0:00.00 as the output
Apparently something to do with the interface between the browser and the computer running the program.
It actually gives a very small time if you increase the precision, but the getline executes pretty much instantly.
It seems that on cpp.sh the program never sees input except in whole lines.
A little testing showed that about 3 out of 5 times, the timer starts as soon as the program runs.
I can't get it to screw up like that. I'm running on linux, so if you're on Windows that could be the difference there. I imagine that only happens if you mistype the alphabet and then retype it without exiting and restarting the program.
Who Seconds L/S
zapshe 0:03.98 6.53
dutch 0:04.43 5.87
agent max 0:07.35 3.54
Yea, I'm running it on Windows. I tested that it starts the timer early by running the program, waiting a couple seconds, then pressing enter. It would say I typed the alphabet wrong and all, but about 3 out of 5 times the timer had several seconds on it instead of just 0.
That issue doesn't exist after the first attempt though. When it gives you another try, the timer never started early.
Sorry to raise a (month) old topic, but figured some explanation about timing issues was in order.
There are a number of reasons the timing could fail.
The compiler is allowed to reorder operations that do not affect each other. This is a well-known problem with timing code snippets. (The code uses OS facilities to reduce the likelihood of that occurring, but not guaranteed, alas.)
The underlying hardware can reorder stuff too! In fact, it can execute things in ways you wouldn't expect. If you google around "pipeline branching/ordering" and the like you can read some weird stuff about how the processor optimizes execution time, and how it can goober some time-sensitive code constructs...
C++ does not directly address these issues as of C++17.
The next problem has to do with input processing. Again, C++ leaves a lot of that to the underlying OS. The code begins timing when input is detected, which may not be exactly what the code intends.
You see this most clearly when running the program through a browser... the server running the code does not receive input until after the user has hit the enter key... which is when the client (your browser) sends the entire string back to the server, giving a cut-n-paste entry time of some microseconds.
Likewise, it is possible that the terminal has sent non-user-input data which you don't see yet still activates the timer and starts the getline() input loop, all before you have pressed a key.
Hope this helps explain some of the weirdness.
Remember, user input is the most evil of all programming problems. Heh...
The faster I type the more I have to press backspace :)
I prefer not to type too fast because it takes thinking about what you type as well, and if you don't think too fast that means your "typing pauses" will be visible more often which makes a bad feeling too.
The faster I type the more I have to press backspace :)
It happens, that's why I like things like Microsoft Word, because it just fixes those minor spelling errors and I don't have to go back and fix them myself.
And I tend to let the words just flow out instead of having to think about each word I type out.
Lol, well I don't tend to misspell when coding. I don't type as fast when coding as when doing something like writing an essay, unless I have the whole program in my head already.
Had no problems with anything being slow, maybe its time to upgrade? Speaking of which, I got VS2022 last night and it works like a charm. Doesn't seem to have the crashing issues I was having with 2019.
The faster I type the more I have to press backspace :)
I prefer not to type too fast because it takes thinking about what you type as well, and if you don't think too fast that means your "typing pauses" will be visible more often which makes a bad feeling too.
Agreed. My project team takes turns writing the monthly report, and every Tuesday (a certain co-worker's day), our group manager would chew us out for writing a terrible report. So I eventually got delegated the job of writing reports, since mine apparently were the best. (Not a complaint, mind you, I like writing reports, especially with too much technical language in them).
Duthomhas wrote:
Remember, user input is the most evil of all programming problems. Heh...
For sure. Right up there with trying to use dynamic memory allocation and forgetting your delete...