Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Check Turing's speed on YOUR computer
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
copthesaint




PostPosted: Mon Jan 12, 2009 11:59 am   Post subject: Check Turing's speed on YOUR computer

This a program I made to see how fast turing will run with my different games.
This is usefull to see how well turing runs on your computer.
The test will take approx. 6 seconds.


NOTE: This is without Graphics.
code:
%This test will takes 6 seconds find how many times your program will loop
%My computer (4 Gb of ram LBTP) runs at 600000-800000
%The first loop is normally the slowest
%Remember this is without pictures, music, drawn objects ect. so this is only what turing is at it's max speed
View.Set ("graphics:max;max;offscreenonly;nocursor")
var timervar, timervar2, checksec, reading1, reading2, reading3, reading4,
    reading5, readingcheck, average : int := 0
Time.Delay (100)
procedure computerspeed
    timervar := Time.Sec
    loop
        timervar2 := Time.Sec
        checksec += 1
        if timervar + 1 <= timervar2 then
            exit
        end if
        %View.Update %if you want to see preformence with graphics on(not pretty the reduction)
        %cls % also see how this change as the graphics size increases (on my LPTB I cut 600000-800000 to 100-200 on max)
    end loop
    if reading1 = 0 and readingcheck = 0 then
        readingcheck := 1
        reading1 := checksec
    elsif reading2 = 0 and readingcheck = 0 then
        readingcheck := 1
        reading2 := checksec
    elsif reading3 = 0 and readingcheck = 0 then
        readingcheck := 1
        reading3 := checksec
    elsif reading4 = 0 and readingcheck = 0 then
        readingcheck := 1
        reading4 := checksec
    elsif reading5 = 0 and readingcheck = 0 then
        readingcheck := 1
        reading5 := checksec
    end if
    checksec := 0
    readingcheck := 0
    timervar := Time.Sec
end computerspeed
for i : 1 .. 5
    computerspeed
end for
average := ((reading1 + reading2 + reading3 + reading4 + reading5) div 5)
timervar := Time.Sec
View.Set ("graphics:400;50;offscreenonly;nocursor")
loop
    timervar2 := Time.Sec
    put ("Your computer loops at an average of "), average, (" loops per 1 second")
    if timervar + 10 <= timervar2 then
        timervar := Time.Sec
    elsif timervar + 8 <= timervar2 then
        put "Reading 5: ", (reading5)
    elsif timervar + 6 <= timervar2 then
        put "Reading 4: ", (reading4)
    elsif timervar + 4 <= timervar2 then
        put "Reading 3: ", (reading3)
    elsif timervar + 2 <= timervar2 then
        put "Reading 2: ", (reading2)
    elsif timervar <= timervar2 then
        put "Reading 1: ", (reading1)
    end if
    View.Update
    cls
end loop
[/code]
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Mon Jan 12, 2009 3:09 pm   Post subject: RE:Check Turing\'s speed on YOUR computer

Turing:
...
var ... reading, reading1, reading2, reading3, reading4, ... : int
...


You're doing it wrong.
S_Grimm




PostPosted: Mon Jan 12, 2009 6:02 pm   Post subject: RE:Check Turing\'s speed on YOUR computer

code:

int reading : array 1..? of int


That would clean it up a lot. my opinon tho. Smile
copthesaint




PostPosted: Mon Jan 12, 2009 7:43 pm   Post subject: RE:Check Turing\'s speed on YOUR computer

Umm I how is it WRONG? I just made them as int because they didn't need a value yet... NE ways use it if YOU want just thought I would share...
michaelp




PostPosted: Mon Jan 12, 2009 7:59 pm   Post subject: RE:Check Turing\'s speed on YOUR computer

They mean you should be using an array. I think. Razz
Clayton




PostPosted: Mon Jan 12, 2009 8:03 pm   Post subject: RE:Check Turing\'s speed on YOUR computer

Yes, if you notice that you're having alot of:

Turing:

var foo1, foo2, foo3, foo4, ... fooX : type


You should probably be using an array:

Turing:
var foo : array 1 .. X of type
andrew.




PostPosted: Mon Jan 12, 2009 8:50 pm   Post subject: Re: RE:Check Turing\'s speed on YOUR computer

copthesaint @ Mon Jan 12, 2009 7:43 pm wrote:
Umm I how is it WRONG? I just made them as int because they didn't need a value yet... NE ways use it if YOU want just thought I would share...
We're not saying you're wrong, we're just offering suggestions to make your code a bit more readable and also so you get a chance to learn arrays because arrays are pretty important in programming.
Parker




PostPosted: Tue Jan 13, 2009 8:42 am   Post subject: RE:Check Turing\'s speed on YOUR computer

Beside from the arrays the program is actually decent. The school computer I am on runs at about 400000, which is considerably slower than you said yours runs at.
Sponsor
Sponsor
Sponsor
sponsor
ecookman




PostPosted: Tue Jan 13, 2009 9:01 am   Post subject: RE:Check Turing\'s speed on YOUR computer

wow my computer must rlly fuck with only a loop of about 30000


cool program
SNIPERDUDE




PostPosted: Tue Jan 13, 2009 9:25 am   Post subject: Re: Check Turing's speed on YOUR computer

Well then, time to clean my computer...

only 22000... Shocked Embarassed Confused


Okay, fixed and much better at 332k.
Good programme. Useful anyways.
Zren




PostPosted: Tue Jan 13, 2009 12:14 pm   Post subject: Re: Check Turing's speed on YOUR computer

I find that the first reading often ends up 1/10th of the maximum as it allocates the stuff into memory or something. You mention that in the header. Though the more times you run it, it will already be in memory and will start with a higher clock/speed. So you could possibly also use this program to test how the time it takes to load into memory.

Max Cycle - First Cycle = Time To Load Into Memory

Since I was intrigued, I redid this using an array and changed the procedure to a function. Somehow I'm getting 1 million (compared to 500 000) on average. I'm just wondering how the hell it jumped to twice as fast...? Are arrays that powerful in memory? Or is it the size of the program?

code:

function compSpeed : int
    var tstart : int := Time.Sec
    var t, cycle : int := 0
    loop
        t := Time.Sec
        exit when t > tstart + 1
        cycle += 1
    end loop
    result cycle
end compSpeed

const READINGS := 5
var speed : array 1 .. READINGS of int
var avg : int := 0
for i : 1 .. READINGS
    speed (i) := compSpeed
    put "Reading ", i, ": ", speed (i)
    avg += speed (i)
end for
avg := round (avg / READINGS)
put "Avg: ", avg
copthesaint




PostPosted: Tue Jan 13, 2009 3:20 pm   Post subject: RE:Check Turing\'s speed on YOUR computer

yes that is a more effective way of doing the program reason for the increase of speed if mostly because you used a function NOT a procedure
Me, I still like my program because I made it Rolling Eyes Smile
DemonWasp




PostPosted: Tue Jan 13, 2009 3:55 pm   Post subject: RE:Check Turing\'s speed on YOUR computer

To respond to Zren, YES arrays can have a huge impact on performance! Here's why:

When you declare everything separately, you have the N variables scattered all through memory. Retrieving any one of those variables will load it from system RAM into your CPU's data cache (generally quite small; a few megabytes at most). Then, if you access another variable that happened to be stored nearby in memory, it may be in the cache. Since the cache responds orders of magnitude faster than the main RAM, this gives a considerable speed boost. However, since we allocated each variable separately, it is at best unlikely that variable2 will be in the same set of memory that variable1 was, and so you'll have to go back to RAM every time.

When you declare variable as an array, you are guaranteed to know that the array is all contiguous (each element right after the one before it, and right before the one after it). The array can still be found in multiple memory blocks, but maybe only 2 or 3 instead of 100+, depending largely on your system setup. Then, the sequential access of each array element will have a considerably higher rate of cache-hits, which is a tremendous speed boost.

I should also mention that a simple linked-list suffers the same problem as single-variables do: their entries may be scattered through RAM, causing access to take a looooong time. This is why lists are often implemented with arrays "behind the scenes" now.

Conclusion: Arrays can give a decent speed boost over single variables.

Auxiliary conclusion: When writing Turing, Holtsoft could have hidden this improvement by putting all the ints into an array based on the locality and name of the variable. Then the speedup would be negligible, though it would perhaps also remove a little bit of the motivation to use arrays.

I don't have Turing (work computer), but I do have Java, so I translated it...even on this relatively tame machine (2.4Ghz P4) I ended up with 14.7 million. It occurs to me that Holtsoft wasn't so concerned with performance. Makes me wish they'd open-source their code, so the language could continue improving - if we're going to be using it to teach students, we kinda owe it to them to improve on that.

Edit: Cool program.

Further Edits: A call to a function isn't substantially different from a call to a procedure. They both take approximately the same length of time, it's just a question of semantics: does the method logically return a value, or not? That's it - no change in performance.
Zren




PostPosted: Tue Jan 13, 2009 6:30 pm   Post subject: Re: Check Turing's speed on YOUR computer

Deamon:
Thanks, that's cool to know. I'm amazed that arrays are actually so powerful and not just easier to use. I also decided to finally read up about why not to use procedures.

Cop:
Sorry for stealing your thunder and going off on a tangent, your program was rather inspiring, the ticker timer for results is an awesome eye candy.
copthesaint




PostPosted: Thu Jan 15, 2009 8:15 am   Post subject: RE:Check Turing\'s speed on YOUR computer

It's fine I don't really care because I know I had The Idead First! ;p Just glad people acually used it
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 21 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: