| View previous topic :: View next topic |
| Author |
Message |
AverageAzn247 Grandmaster Cheater
Reputation: 34
Joined: 01 Oct 2007 Posts: 909 Location: Austin,TX with 72 virgins
|
Posted: Sat Jan 28, 2012 12:57 pm Post subject: c++ program hanging |
|
|
my program is hanging and i have no clue why. It is supposed to time how long it took to do mysize() and two different types of push
http://www.mediafire.com/?abcou6d5iiis969 | Code: | /*
* This program demonstrates how to calculate the actual
* processing time of a part of your program, say the
* execution time of function f(). The program uses the
* function clock(), the clock_t type, and the constant
* CLOCKS_PER_SEC defined in the C++ standard library "ctime".
*/
// be sure to include <ctime>
#include<ctime>
#include<cmath>
#include<iostream>
#include "ArrayStack.h"
using namespace std;
int main()
{
for (int k=1; k<20; k++)//time for using mysize
{
int input_size=pow(2.0,k);
ArrayStack <int> S;
int size_prog=0;
int run_time= (1000000/input_size)+10;
clock_t start=clock();
for( int i=0; i<run_time;i++)
{
for(int i=0; i<input_size;i++)
{
S.push(i);
}
S.mySize();
}
clock_t end=clock();
cout<<"For My_Size" << "size "<< input_size<<" "<<"CPU elapsed time in seconds: "<<(double)(end - start)/CLOCKS_PER_SEC/run_time <<endl;
}
for (int k=1; k<20; k++)//looop for differing size 2 to 2^20
{
int input_size=pow(2.0,k);
ArrayStack <int> S;
int run_time= (1000000/input_size)+10;
clock_t start=clock();
for( int i=0; i<run_time;i++)
{
for(int i=0; i<input_size;i++)//pushing looop
{
S.push(i);
}
} //int b=S.size();
//cout<<"clock time " <<end<< " size "<< input_size<< "my size"<< a"\n";
}
for (int k=1; k<20; k++)//looop for differing size 2 to 2^20
{
int input_size=pow(2.0,k);
ArrayStack <int> S;
int run_time= (1000000/input_size)+10;
clock_t start=clock();
for( int i=0; i<run_time;i++)
{
for(int i=0; i<input_size;i++)//pushing looop
{
S.push_cons(i);
}
}//int b=S.size();
clock_t end=clock();
cout<<"For pushing using constant " << "size "<< input_size<<" "<<"CPU elapsed time in seconds: "<<(double)(end - start)/CLOCKS_PER_SEC/run_time <<endl;
}
return 0;
}
/*
* Reference:
* A program described in B. Stroustrup: Wrapping C++ Member Function Calls
* "The C++ Report" June 2000
* http://www.research.att.com/~bs/wrap_code.cpp
*/
|
_________________
| Waxxup wrote: | What are Night Elves?
A girl group? |
Last edited by AverageAzn247 on Sat Jan 28, 2012 3:16 pm; edited 1 time in total |
|
| Back to top |
|
 |
manc Grandmaster Cheater
Reputation: 1
Joined: 16 Jun 2006 Posts: 551
|
Posted: Sat Jan 28, 2012 2:04 pm Post subject: |
|
|
I'm not gonna download a .7z file to help you...especially when it says assignment1. Posting school HW? lol
Either way, just post the code here dude.
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Jan 28, 2012 2:39 pm Post subject: |
|
|
| manc wrote: | I'm not gonna download a .7z file to help you...especially when it says assignment1. Posting school HW? lol
Either way, just post the code here dude. |
The code is in the zip.
_________________
- Retired. |
|
| Back to top |
|
 |
AverageAzn247 Grandmaster Cheater
Reputation: 34
Joined: 01 Oct 2007 Posts: 909 Location: Austin,TX with 72 virgins
|
Posted: Sat Jan 28, 2012 4:18 pm Post subject: |
|
|
nvm i figured it out. I moved the loop that did the pushing out. It got hung somewhere in there
_________________
| Waxxup wrote: | What are Night Elves?
A girl group? |
|
|
| Back to top |
|
 |
Elitekiller How do I cheat?
Reputation: 0
Joined: 03 Feb 2012 Posts: 5
|
Posted: Fri Feb 03, 2012 6:20 am Post subject: |
|
|
| Even I got That stuck in this code...
|
|
| Back to top |
|
 |
|