I am sure there are a number or people here like me that have dipped there toes in scripting/programming, using it for automating simple tasks and automating repetive management jobs. But thats really as far as I have taken it, never needing to go deeper or really worry about optimizing code.
But a few days ago I sat down and put together the few lines of code below.
What this is doing is creating 500 ellipse's, and calculating the points on the circumference for each at a given degree. Then incrementing the value for the degrees and recalculating.
On a 800Mhz CPU this runs at about 80 cycles per second. Which although is quick, moving up to 2000 ellipses's and it drops to 25 per second.
So how do the likes of Games manage to get such performance out of a system. Enemy AI, Player input, Environmental interaction. All must require much more complex processing than this, but frame rates of 80+ are not uncommon. And even with the off loading of the Graphics and physics to the GPU, the core of the application must still be run on the CPU.
I am starting to think that far from being poorly coded and bloated which I felt games had become since the good old days of the Atara and Amiga with there 2K footprints. The Guys out there today are still managing to squease a lot of game out off the resources the have at there disposal.
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark;
use Math::Trig;
my $i = 0;
my $x = 0;
my @Degre = map {rand(360)} (0..499);
my @step= map {rand(.5)} (0..499);
my @aa = map {rand(2000)} (0..499);
my @bb = map {rand(2000)} (0..499);
timethis(100,'
$xx[$_] = $aa[$_]*(cos($Degre[$_])*(pi/180)) for (0..499);
$yy[$_] = $bb[$_]*(cos($Degre[$_])*(pi/180)) for (0..499);
$Degre[$_] += $step[$_] for (0..499);
#print "$bb[1] $aa[1] $Degre[1] $step[1] \n";
');