I made some programs at my house and they run find but I trying them out on my schools computer and it runs slow. any tips on how I can make my codes better so that it runs the same for most computer?
I made some programs at my house and they run find but I trying them out on my schools computer and it runs slow. any tips on how I can make my codes better so that it runs the same for most computer?
(Dante)"Blood you have thirsted for -- now, drink your own!"
Maybe your computer at school doesn't have enough memories for your programs.
My tip to make your code faster: change your algorithm.
Without any info on the code, there's nothing more I can say.
Can you show some of your codes? Maybe someone will fix it for u out of the goodness of there heart.
First, make sure it's CPU-bound. If it's I/O bound (to harddrive, for example), there is not much you can do except changing the algorithm.
Otherwise profile the code, look for the performance bottleneck, and try to rewrite it to make it faster.
But yeah, nothing much we can do without seeing the code.
We can't give you specific help without at least SOME understanding of what your code does.
I wrote up some hints on how to measure/improve performance:
http://apps.sourceforge.net/mediawik...d_optimization
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Very basic but it's the only one I have on me at school : (Code:#include <iostream> #include <time.h> #include <math.h> #include <stdlib.h> #include <stdio.h> using namespace std; int main () { srand ( time ( NULL ) ); short int NumGuess; int InvisableNum = ( rand () % 100 ) + 1; short int num = 0; system("COLOR 7"); cout << " \t \t Guessing Game" << endl << endl; do { cout << "Guess a number between 1 - 100 (0 to exit): "; cin >> NumGuess; if ( NumGuess > InvisableNum ) { cout << endl; cout << "To High! " << endl << endl; } else if ( NumGuess < InvisableNum ) { cout << endl; cout << "To Low! " << endl << endl; } num++; if ( NumGuess == InvisableNum ) { cout << endl << endl; cout << "You are right!!, it took you " << num << " trys" << endl << endl; cout << endl; } } while ( NumGuess != InvisableNum ); system("pause"); return(0); }
(Dante)"Blood you have thirsted for -- now, drink your own!"
You are saying that this program runs too slow?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I guess the only things that might be too slow are the system calls. Don't use external programs for these things or just live with it...
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
that should run like gangbusters on a 286
On a windows platform, it MAY run slow if the graphics card isn't accellerating certan bitblt l operations used for scrolling the screen. Try switching to full-screen mode (ALT-ENTER in a command prompt). Or simply reduce the number of "endl" to reduce the amount of scrolling in the first place.
But yess, I agreee with m37h0d - it shouldn't run slow on any computer produced in the last 15 years or so.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.