Not thought of div and ldiv. So wrappeed them into the test sketch :
testing divmod10()
i/10 38.6920
i%10 38.6120
--------------
ldiv 44.7880
--------------
div 15.3960
--------------
divmod10 14.9200
--------------
test div 0..65535
test mod 0..65535
test div 0..maxlong (20K random samples)
test mod 0..maxlong (20K random samples)
done
ldiv is very interesting as for almost the same performance one gets / & %
div is 16 bit and signed, where the rest is 32 bit (unsigned), still interesting numbers.
Should make a 16 bit test version.
snippet to add
Serial.print("ldiv\t");
start = micros();
ldiv_t ld;
volatile long x;
for (unsigned long i = 0; i < 1000; i++)
{
ld = ldiv(i,10);
}
stop = micros();
Serial.println((stop - start)/1000.0, 4);
Serial.println("--------------");
x = ld.quot;
Serial.print("div\t");
start = micros();
div_t id;
for (unsigned long i = 0; i < 1000; i++)
{
id = div(i,10);
}
stop = micros();
Serial.println((stop - start)/1000.0, 4);
Serial.println("--------------");
x = id.quot;