Comparison between programming environments TouchDevelop and Wake
Time test with loop from 1 to 100000
TouchDevelop: from 14 milliseconds to 82 milliseconds
Wake: 4346 microseconds to 8335 microseconds (4.3 to 8.3 milliseconds)
Result: Wake is faster
Comparison with Python 3
import time
a = time.time()
for i in range(1, 100000000):
b = i * 0.1
print(int(time.time() - a))
about 45 seconds with old MacBook
time
1 1 100000000 {/b exch 0.1 mul def} for
time exch sub =
about 16 seconds
about 2-3 times faster than Python 3
Time test with loop from 1 to 100000
TouchDevelop: from 14 milliseconds to 82 milliseconds
Wake: 4346 microseconds to 8335 microseconds (4.3 to 8.3 milliseconds)
Result: Wake is faster
Comparison with Python 3
import time
a = time.time()
for i in range(1, 100000000):
b = i * 0.1
print(int(time.time() - a))
about 45 seconds with old MacBook
time
1 1 100000000 {/b exch 0.1 mul def} for
time exch sub =
about 16 seconds
about 2-3 times faster than Python 3
C-code implementing for-loop function in Wake interpreter:
/* init incr limit block - for - */
void wk_for(void)
{
int xst;
jmp_buf xjb;
check(4);
if (wsp[-1].type!=BLOCK_TYPE) error(WAKE_INVALID_TYPE);
memcpy(xjb, exit_jump, sizeof(jmp_buf));
xst=exit_est;
exit_est=est;
push(wsp-1);
exec_stack[est-1].element.unit.head[-1].prot++;
if (!setjmp(exit_jump)) {
if (wsp[-4].type!=INTEGER_TYPE||wsp[-3].type!=INTEGER_TYPE||
wsp[-2].type!=INTEGER_TYPE)
if (wsp[-4].type!=UINTEGER_TYPE||wsp[-3].type!=UINTEGER_TYPE||
wsp[-2].type!=UINTEGER_TYPE)
if (wsp[-4].type!=FLOATING_TYPE||wsp[-3].type!=FLOATING_TYPE||
wsp[-2].type!=FLOATING_TYPE) {
ELEMENT ini=wsp[-4], inc=wsp[-3], lim=wsp[-2], zero;
zero.flag=NUMBER|INTEGER;
zero.type=INTEGER_TYPE;
zero.unit.integer=0;
wsp-=4;
if (gt(&inc, &zero))
while (le(&ini, &lim)) {
stack(1);
*wsp=ini;
wsp++;
execute();
addf(&ini, &ini, &inc);
}
else
while (ge(&ini, &lim)) {
stack(1);
*wsp=ini;
wsp++;
execute();
addf(&ini, &ini, &inc);
}
}
else {
double fini=wsp[-4].unit.floating, finc=wsp[-3].unit.floating, flim=wsp[-2].unit.floating;
wsp-=4;
if (finc>0)
while (fini<=flim) {
stack(1);
wsp->flag=NUMBER;
wsp->type=FLOATING_TYPE;
wsp->unit.floating=fini;
wsp++;
execute();
fini+=finc;
}
else
while (fini>=flim) {
stack(1);
wsp->flag=NUMBER;
wsp->type=FLOATING_TYPE;
wsp->unit.floating=fini;
wsp++;
execute();
fini+=finc;
}
}
else {
ULONG ini=wsp[-4].unit.uinteger, inc=wsp[-3].unit.uinteger, lim=wsp[-2].unit.uinteger;
wsp-=4;
while (ini<=lim) {
stack(1);
wsp->flag=NUMBER|INTEGER;
wsp->type=UINTEGER_TYPE;
wsp->unit.uinteger=ini;
wsp++;
execute();
ini+=inc;
}
}
else {
long ini=wsp[-4].unit.integer, inc=wsp[-3].unit.integer, lim=wsp[-2].unit.integer;
wsp-=4;
if (inc>0)
while (ini<=lim) {
stack(1);
wsp->flag=NUMBER|INTEGER;
wsp->type=INTEGER_TYPE;
wsp->unit.integer=ini;
wsp++;
execute();
ini+=inc;
}
else
while (ini>=lim) {
stack(1);
wsp->flag=NUMBER|INTEGER;
wsp->type=INTEGER_TYPE;
wsp->unit.integer=ini;
wsp++;
execute();
ini+=inc;
}
}
}
memcpy(exit_jump, xjb, sizeof(jmp_buf));
est=exit_est;
exit_est=xst;
eel= &exec_stack[est-1].exec_elem;
exec_stack[est].element.unit.head[-1].prot--;
}