The city of Nice seen from the surrounding hillside bathed in sunshine

Home Ren's Biking Blog

Reaction Tester

Blog Date 22 August 2019

I am a nerd, I am a geek. As part of my professional nerdiness I use Javascript. As a little exercise I've created a simple reaction tester. The box below (should) be a light tan colour. Click on the "Start" button and wait until the box turns bright red. When it does click anywhere in the red box...




If you'd like some Javascript nonsense contact ren@bikesandtravels.com

Reader's Comments

Ian Soady said :-
Interesting. It's like this one: https://www.humanbenchmark.com/tests/reactiontime except of course the colours are different.

What of course is really odd is that on that one I get an average of 0.26 seconds (not bad for 70 years old especially as it's better than the median /means they give) whereas yours gives me round about 0.370........
https://www.humanbenchmark.com/tests/reactiontime...
22/8/2019 4:38:16 PM UTC
Ren - The Ed¹ said :-
I'm getting about the same for both - about 310-340. It is possible my code is not as "sharp" as theirs :-)
22/8/2019 4:55:17 PM UTC
Ian Soady said :-
Maybe it's your server that's slow?
22/8/2019 5:21:19 PM UTC
Ren - The Ed¹ said :-
It's not done on the server Ian. It's all done in the browser.
22/8/2019 6:37:05 PM UTC
Ian Soady said :-
Shows you how much I know about this newfangled stuff....

Is it browser dependent? I use firefox on W10 pro.
23/8/2019 11:34:27 AM UTC
Ren - The Ed¹ said :-
Javascript is run on the client side, at your PC within the browser. All the major browsers have a javascript engine within them. Of course how this javascript is interpreted and parsed by each browser is another thing. Also the client, ie you, can choose to turn off the javascript engine.

The javascript in this example is very very simple indeed. If you right click the page and choose "view page source" you will be able to read it clearly especially with your experience.
23/8/2019 1:51:55 PM UTC
Ian Soady said :-
Not much to it as you say. I take it that date / time differences are in milliseconds?

Don't like the repeated use of the same variable name (x) but won't do any harm I suppose. Why do you need to initialise MyText to "" as it can only be one of the "proper" values? It looks as though StartTime is undefined until the first x (ie the time at which the colour changes) hasn't been reached when you click. I would have assigned it a known value.....

But it works. Why it gives a different answer to the other one I don't know however. The code for that one looks much more complicated.......

If you're bored and want some work to do I have a little task which involves collecting data from a database behind a website.......
23/8/2019 2:28:31 PM UTC
Ren - The Ed¹ said :-
In JS at least if the variable is declared in the function it is only available to that function. Hence x can be used many times in the same program just not the same function.

I don't know why I declared MyText as "" - probably a kickback from other languages that don't like to be declared with at least some empty value. Habits.

JS goes back to the old Unix days. As such Date.now() will return - ahem - the number of MILLISECONDS since January 1, 1970 12:00:00 GMT. Typically Unix just did it to the second, JS adds on the milliseconds. Of course we will reach the Unix Epoch on January 19, 2038 03:14:08 GMT when we run out of 32bit numbers to count with. Then the end of the world will arrive.

I'm deffo not bored - but - email me, I'll see if I can help
23/8/2019 8:44:54 PM UTC
Ian Soady said :-
End of the world? It'll be like Y2K. What makes me smile is how everyone says "Oh, what a fuss about nothing that was". They're totally unaware of the huge effort put in all over the world to find and correct 2 digit years. A colleague of mine at the time supervised this for the NHS and it turned him prematurely grey.

Like many other programmers in the 80s and earlier, I used 2 digit years with abandon - first because it never struck me there might be a problem; second if it had I'd have assumed my code would have been long gone (and so would I!); third because storage space was so tight. We used among other things DEC 5 MB removable disc drives that were about the size and weight of my Norton's front wheel. That's around 1/10,0000 of the memory on the average current smartphone so any saving was worthwhile. I remember one system where we actually used a packing technique to get dates down to (IIRC) 10 bits.......

email sent...
24/8/2019 11:46:28 AM UTC
CrazyFrog said :-
I used to repair Diablo 5mb removable drives Ian, and the big(!) CDC 7 plater 288mb removable drives. IIRC, the CDC drives used to need a 40 amp supply as they drew very nearly that on start up. I also used to repair the big tape drives, card readers and punches and ticker tape readers and punches. I must be getting old! :-(
26/8/2019 8:06:09 PM UTC
CrazyFrog said :-
When I first started coding Wang assembler (same as IBM 370 assembler) the instruction code book used to give timings for each instruction so you could optimizer your code! I used to really enjoy coding then, it's certainly not as creative now, I don't think...
26/8/2019 8:09:25 PM UTC
Ren - The Ed¹ said :-
Good lord and I thought I was a nerd. I suppose I can only hope that one day I'll be on a forum saying "When I were a middle aged man I used to program code using a keyboard! None of this AI self programming nonsense, we had to learn it and write it." Meanwhile our robotic overlords will bless us with morsels of food if there is a surplus in the energy system...


27/8/2019 9:02:38 AM UTC
Ian Soady said :-
You're just a youth, sit back and let us "real" programmers tell our war stories....

I still enjoy coding although these days mostly visual basic embedded in Access databases. Nowadays I concentrate on readability and elegance* rather than efficiency.......

My favourite language was RTL/2 which ran on DEC PDPs under RSTS operating system. Very flexible and powerful. We used it for real time systems controlling vehicle assembly at Austin Rover's Longbridge and Cowley plants, although I was more system analysis and design than coding by then.


*well that's what I call it
27/8/2019 10:17:11 AM UTC
Pocketpete said :-
Rpg 2 running on a Cincinnati milacron server 5mb platters where the heads floated and crashed.. so much fun
27/8/2019 7:40:01 PM UTC

Post Your Comment Posts/Links Rules

Name

Comment

Add a RELEVANT link (not required)

Upload an image (not required)

No uploaded image
Real Person Number
Please enter the above number below




Home Ren's Biking Blog

Admin -- --