I don't understand this bug

Your loop() runs with very high speed. There is no limit for the speed. It runs faster than once per millisecond. That means that "mytimer += timeloop" is executated very often, and the 1000 is reached before you know it.

Why not measure it like everyone does:

unsigned long t1, t2, t;
t1 = micros();
....  // here the code to test
t2 = micros();
t = t2 - t1;