|
-
Learning Flash
hmmm... does this work? maybe more efficient than c/c (as if it mattered!)
if (c-c!=0)
EDIT: no, silly me, as soon as the / or - operator sees it's dealing with a non-numeric string, it will return undefined. It won't actually do any division or subtraction. So same efficiency.
EDIT2: or
if (c*0!=0)
Or, could do:
if (isNaN(parseInt(c)))
Last edited by yow; 07-19-2007 at 04:28 AM.
code tested in Flash Basic 8 (AS2), Windows XP
-
Pumpkin Carving 2008
Code:
100000 Dividing Comparisons Avg: 0.0464 s
100000 Subtracting Comparisons Avg: 0.0457 s
---
100000 Dividing Comparisons Avg: 0.0449 s
100000 Subtracting Comparisons Avg: 0.0463 s
---
100000 Dividing Comparisons Avg: 0.0527 s
100000 Subtracting Comparisons Avg: 0.046 s
---
100000 Dividing Comparisons Avg: 0.0525 s
100000 Subtracting Comparisons Avg: 0.0455 s
---
100000 Dividing Comparisons Avg: 0.0456 s
100000 Subtracting Comparisons Avg: 0.0465 s
---
100000 Dividing Comparisons Avg: 0.0454 s
100000 Subtracting Comparisons Avg: 0.0452 s
---
100000 Dividing Comparisons Avg: 0.0464 s
100000 Subtracting Comparisons Avg: 0.0457 s
---
100000 Dividing Comparisons Avg: 0.045 s
100000 Subtracting Comparisons Avg: 0.0467 s
---
100000 Dividing Comparisons Avg: 0.0462 s
100000 Subtracting Comparisons Avg: 0.0464 s
---
100000 Dividing Comparisons Avg: 0.0451 s
100000 Subtracting Comparisons Avg: 0.046 s
Grand Totals:
PHP Code:
1 Million Dividing Comparisons Avg: 0.04702 s
1 Million Subtracting Comparisons Avg: 0.04618 s
Looks like dividing is actually faster, but, probably negligible.
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
-
Learning Flash
That's the way, do the experiment!
But I bet the variation in times is mostly due to Flash noise... over 10 trials, a difference of (0.04702-0.04618) /( (0.04702+0.04618)/2 ) * 100 is only 1.8%... and given the wideness of the variation in the 10 trials (0.0449 - 0.0527 sec for dividing - almost 16%), I'd guess this isn't significant.
If you run it again, I wonder if the overall averages will differ markedly?
100 trials (or 1000) would smooth out this particular source of randomness. hehehe but I really prefer my computational machinery to be deterministic!
PS: I used google to calc the %. convenient
code tested in Flash Basic 8 (AS2), Windows XP
-
Learning Flash
if (c>-1)
Code:
check("a");
check("0");
check("9");
function check(c) {
trace(c)
trace(c>-1)
if (c>-1) trace("digit")
else trace("not a digit");
trace("")
}
EDIT1: and I realize now that of course c/c or c-c will do some calculation - when c is numeric.
Last edited by yow; 07-20-2007 at 02:50 AM.
code tested in Flash Basic 8 (AS2), Windows XP
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|