Can't wait!
Can't wait!
Have you checked out the front page lately?
Projects:
Moe's Tavern | Sponsored by: Mimo Monitors, Crucial, Thermaltake
Book Of Knowledge
And the results are in, honstly im suppurised at them.
And helix, your app didn't have a counter and you didn't reply with a revision that did so, in efect your app does not have any scores becuase i couldn't get any.
its strange i think, VB has 2 out of 5 victorys and Java has 2 out of 5, and C++ has only 1 out of 5.
I was expecting C++ to wipe the floor with everything, but apperently not!
so who won?
"At the midpoint on the journey of life, I found myself in a dark forest, for the clear path was lost..." -Dante Alighieri
Yeah, who won?
I can see that VB (my program) wins in the shorter countings, but java (trace) takes over at the larger numbers. Also C++ (Mtekk) is quicker at those numbers.
It seems to me that both Java and C++ count faster, but the program takes a little time to initialize or somthing, since the lower numbers all take about 15-16ms...
Anyways, good job you all!
now: let's see the sources
In all reality, there are much faster ways of doing this in C++, but mine was the quickest to write, and kept with the STL. I wrote it in the middle of two weeks filled with midterms. Prince probably used vectors, but probably didn't do any preallocation which decreases performance (mine preallocated before counting). I think the timing method I used isn't necessarily the best either, it's resolution is a little low (has a resolution of 1ms).
I'd like to see the code silverdemon used. Mine is in the bottom of this post.
Just out of curiosity, did you do multiple runs and average them? And what system specs?
Here's my code
Code:/* John Havlik 4-18-2008 Count Benchmark */ #include <iostream> #include <vector> #include <fstream> #include <ctime> using namespace std; int main() { clock_t start, end, elapsed; vectordump; unsigned char foo; unsigned int count(1000000), temp(0); do { cout << "How many iterations do you want to do?\n"; cin >> temp; count = ++temp; dump.assign(count, 0); start = clock(); while(--count) { dump[count] = count; }; end = clock(); elapsed = end - start; cout << "For " << temp << " loops (count from 0 to " << temp - 1 << ")\n We took: " << elapsed << " ms \n Saving..."; ofstream fout; fout.open("count.out"); for(unsigned int i(0); i < temp; i++) { fout << dump[i] << endl; } fout.close(); dump.clear(); cout << " Done.\nWould you like to run again?(y/n)\n"; cin >> foo; } while(foo == 'y'); return 0; }
Well, who won?
My code is below.
I entered the second 1.
If you want my VB6 code let me know.(PM)
Java (with output):
Java(without output):Code:import java.io.File; import java.io.FileNotFoundException; import java.io.PrintStream; import java.util.Scanner; class Count2 { public static void main(String args[]) throws FileNotFoundException { Scanner input = new Scanner( System.in ); PrintStream diskWriter = new PrintStream( "D:/java/numbers.txt" ); System.out.print( "Enter number to count to: " ); int countto = input.nextInt(); int count = 0; long time = System.currentTimeMillis(); while (count < countto) { count = count + 1; diskWriter.println( count ); } long timeTook = System.currentTimeMillis() - time; System.out.println("It took you "+timeTook+"ms to count to "+count); } }
Code:import java.util.Scanner; public class Count { public static void main( String args[] ) { Scanner input = new Scanner( System.in ); System.out.print( "Enter number to count to: " ); int countto = input.nextInt(); int count = 0; long time = System.currentTimeMillis(); while ( count < countto) { count = count + 1; } long timeTook = System.currentTimeMillis() - time; System.out.println("It took you "+timeTook+"ms to count to "+count); } }
Have you checked out the front page lately?
Projects:
Moe's Tavern | Sponsored by: Mimo Monitors, Crucial, Thermaltake
Book Of Knowledge
Just for fun I opened up Mathematica and did some plots of the times. For the following plots, orange is Trace, blue is me (mtekk), red is Silverdemon, and green is Prince.
Here's Trace's Time vs. Count graph
Here's My Time vs. Count graph
Here's Silverdemon's Time vs. Count graph
Here's Prince's Time vs. Count graph
Here is a combined, graph on the common axis of Prince's plot.
Wait, I think that's the one I entered. I'm not completely sure actually.
Have you checked out the front page lately?
Projects:
Moe's Tavern | Sponsored by: Mimo Monitors, Crucial, Thermaltake
Book Of Knowledge