Re:Althttpd: Simple webserver in a single C file
by pjc50 on Tuesday June 08, 2021 @05:26AM
(#27432193)
There's only two billion integers, guess we can test them all. Well, substantially fewer than two billion with that skip. I wonder if that completes in a few seconds.
[ Parent
| on HN ]
Re:Althttpd: Simple webserver in a single C file
by unwind on Tuesday June 08, 2021 @07:14AM
(#27433572)
That was quite easy to cut and paste and compile:
$ time ./althttpd-time-parse
Test completed in 10518961 us
real 0m10,521s
user 0m10,486s
sys 0m0,004s
The "Test completed" line is from my main() "driver", I wanted to measure time inline too and the measurements seem to agree.This is on a Dell Latitude featuring a Core i5-7300U at 2.6 GHz, running Ubuntu 20.10.
Re:Althttpd: Simple webserver in a single C file
by nneonneo on Tuesday June 08, 2021 @05:34AM
(#27432236)
This loop doesn’t test them all - it tests every 1/127th integer, so it only runs about 16 million times.
Re:Althttpd: Simple webserver in a single C file
by Cthulhu_ on Tuesday June 08, 2021 @05:56AM
(#27432388)
And a modern CPU runs billions of instructions per second, so it shouldn't take too long at all. Depends on the implementation of the function as well though, and how the compiler can optimize, unroll or optimize both the function under test and the test itself.
Re:Althttpd: Simple webserver in a single C file
by postalrat on Tuesday June 08, 2021 @12:49PM
(#27437621)
How would you write a better test?
IMO most tests are fundamentally flawed. The way most testing is done it would be easier and better to just write everything twice, have a method to compare results, and hope you got it right at least once.
Re:Althttpd: Simple webserver in a single C file
by louisvgchi on Tuesday June 08, 2021 @05:20PM
(#27441015)
I do think of tests as a kind of double accounting.
Re:Althttpd: Simple webserver in a single C file
by ithkuil on Tuesday June 08, 2021 @05:28AM
(#27432205)
Computers are insanely fast
Re:Althttpd: Simple webserver in a single C file
by tyingq on Tuesday June 08, 2021 @10:20AM
(#27435534)
Another comment shows 10 seconds on a relatively decent CPU from 2017. So it is a fairly heavyweight task, though I suppose could be rewritten to use more than one core.
Re:Althttpd: Simple webserver in a single C file
by ithkuil on Wednesday June 09, 2021 @03:54AM
(#27445361)
yeah, that's a lot of iterations :-)
I was curious to see how my M1 compares to my intel 2019 macbook pro:
M1:
/tmp/tt 8.42s user 0.01s system 99% cpu 8.435 total
2,6 GHz 6-Core Intel Core i7
/tmp/tt 15.69s user 0.03s system 98% cpu 15.888 total
/tmp/tt 15.69s user 0.03s system 98% cpu 15.888 total