Advertisement
Guest User

Untitled

a guest
May 5th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <vector>
  2.  
  3. namespace somename
  4. {
  5.   static float array[100];
  6. };
  7.  
  8. class Trial {
  9. public:
  10.     float some_function(std::vector<float>& input)
  11.     {
  12.         float result = 0.0;
  13.  
  14.         for(int i=0; i<100 && i < input.size(); i++) {
  15.             somename::array[i] = input[i];
  16.             result += somename::array[i];
  17.         }
  18.  
  19.         return result;
  20.     }
  21. };
  22.  
  23. class Trial2 {
  24.     public:
  25.         float some_function(std::vector<float>& input)
  26.         {
  27.             static float array2[100];
  28.             float result = 0.0;
  29.  
  30.             for(int i=0; i<100 && i < input.size(); i++) {
  31.                 array2[i] = input[i];
  32.                 result += array2[i];
  33.             }
  34.  
  35.             return result;
  36.         }
  37. };
  38.  
  39. int main() {
  40.     std::vector<float> input;
  41.    
  42.     input.push_back(10);
  43.     input.push_back(1);
  44.     input.push_back(3);
  45.     input.push_back(56);
  46.     input.push_back(3457);
  47.     input.push_back(867);
  48.     input.push_back(323);
  49.     input.push_back(128);
  50.     input.push_back(978);
  51.     input.push_back(235);
  52.     input.push_back(9);
  53.     input.push_back(83);
  54.     input.push_back(34);
  55.    
  56.     Trial x;
  57.     for(int i=0; i<100000000; i++) {
  58.         x.some_function(input);
  59.     }
  60.    
  61.     /**
  62.     Trial2 y;
  63.     for(int i=0; i<100000000; i++) {
  64.         y.some_function(input);
  65.     }**/
  66.    
  67.     return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement