Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,626 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,060 people online right now. Registration is fast and FREE... Join Now!




Java and C++ Help

 
Reply to this topicStart new topic

Java and C++ Help, For a research project thingy

BlackJesus
post 1 Sep, 2005 - 12:12 PM
Post #1


D.I.C Head

Group Icon
Joined: 10 Feb, 2005
Posts: 161



Thanked 1 times

Dream Kudos: 175
My Contributions


Hey guys i have to do some research project thing for class...so i chose to do computer science. and now somehow i have to write a networked 2 player tic tac toe game in java and c++ and compare the speeds. i was wondering if and how its possible to compare the speeds of these programs when both will run so fast. should i use a timer inside the program that displays when the player moved or something? thanks in advance for any help
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 1 Sep, 2005 - 12:24 PM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,176



Thanked 33 times

Dream Kudos: 25
My Contributions


You've hit the nail on the head...first, decide what events you want to compare time wise ( a single completed move, a group of moves, one game, the entire execution, loops etc...). you will then start a timer at the beginning of each event (or take a read of the system time) and end that timer immediately after the event (or take another read of the system time and subtract).
User is offlineProfile CardPM

Go to the top of the page

1lacca
post 9 Sep, 2005 - 04:09 AM
Post #3


code.rascal

Group Icon
Joined: 11 Aug, 2005
Posts: 3,822



Thanked 11 times
My Contributions


Yes, this is the basic idea, but it takes a bit more thinking to get meaningful measurements!
First of all, the system time is not too accurate, so for measuring "short" events it is not too useful - like making a move /supposedly its not done by an AI/. Maybe running them like 1000 times, and dividing the data by 1000 gives a more precise answer though!
I would suggest running your programs with a set sequence of steps made by the players, and measuring the total execution time. Also it is worth to do the measuring a couple of times, as the first execution is supposed to last much longer - homework is to find a reasoning for this tongue.gif
Finally if the main goal is to comapre c++ and java speed, it is also interesting to decide if you gonna use a direct (naive) port of your program on both platforms, or you might try to take advantage of the specifics of each environment.
I hope I havent raised more questions than answered ....

This post has been edited by 1lacca: 9 Sep, 2005 - 04:27 AM
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 9 Sep, 2005 - 04:21 AM
Post #4


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,176



Thanked 33 times

Dream Kudos: 25
My Contributions


I'll agree that the system time is not perfectly accurate...that is why I suggested using timers as the primary approach.

And 1lacca is absolutely right in the fact that you should never, ever, perform only one test of this nature...many multiples should be run, and the averages taken for a more indicative result. Many things can effect the timing of a program.
User is offlineProfile CardPM

Go to the top of the page

1lacca
post 9 Sep, 2005 - 04:29 AM
Post #5


code.rascal

Group Icon
Joined: 11 Aug, 2005
Posts: 3,822



Thanked 11 times
My Contributions


Indeed, timers are usually more accurate!
User is offlineProfile CardPM

Go to the top of the page

Nova Dragoon
post 9 Sep, 2005 - 08:02 AM
Post #6


The Innocent Shall Suffer, Big Time

Group Icon
Joined: 16 Aug, 2001
Posts: 6,128



Thanked 4 times

Dream Kudos: 515

Expert In: Python, Linux

My Contributions


QUOTE(BlackJesus @ Sep 1 2005, 02:12 PM)
Hey guys i have to do some research project thing for class...so i chose to do computer science. and now somehow i have to write a networked 2 player tic tac toe game in java and c++ and compare the speeds. i was wondering if and how its possible to compare the speeds of these programs when both will run so fast. should i use a timer inside the program that displays when the player moved or something? thanks in advance for any help

Are there people actually going to be playing these games or is it going to be scripted or possibly ai playing?

If you got it to run automonously. there are several tools for timing the execution such as 'times' and there are prolly some for the windows platform. With that case, you can run the experiment all night while to sleep and get a very good sample.
User is offlineProfile CardPM

Go to the top of the page

dntchaseme
post 4 Oct, 2005 - 10:44 AM
Post #7


New D.I.C Head

*
Joined: 4 Oct, 2005
Posts: 2


My Contributions


hey man
Thanks for suggestions...............i apreciat them and these are very use full for me
Imran Hashmi www.visionstudio.co.uk 0044-7969012441
Imran Hashmi www.seo-professional.co.uk 0044-7969012441
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 03:33AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month