Changeset 16 for cppstreams/test_fibonacci.cc
- Timestamp:
- Dec 5, 2012, 10:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cppstreams/test_fibonacci.cc
r3 r16 9 9 * Redistribution and use in source and binary forms, with or without 10 10 * modification, are permitted provided that the following conditions are met: 11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright 12 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright 14 14 * notice, this list of conditions and the following disclaimer in the 15 15 * documentation and/or other materials provided with the distribution. … … 52 52 int main() 53 53 { 54 stream<long> s = 0l<<=s+(1l<<=s); 55 compare(s, {0l,1l,1l,2l,3l,5l,8l,13l,21l,34l}, 1); 54 stream<long> s = 0l<<=s+(1l<<=s); 56 55 57 const int n = 200000; 58 struct timeval tv1, tv2; 59 struct timezone tz; 56 compare(s, {0l,1l,1l,2l,3l,5l,8l,13l,21l,34l}, 1); 60 57 61 gettimeofday(&tv1, &tz); 62 stream<long>::iterator it = s.begin(); 63 for(int i=0; i<n; ++i) ++it; 64 *it; 65 gettimeofday(&tv2, &tz); 66 std::cout<<timeval_diff(tv2, tv1)<<std::endl; 58 const int n = 200000; 59 struct timeval tv1, tv2; 60 struct timezone tz; 67 61 68 gettimeofday(&tv1, &tz); 69 fib(n); 70 gettimeofday(&tv2, &tz); 71 std::cout<<timeval_diff(tv2, tv1)<<std::endl; 62 gettimeofday(&tv1, &tz); 63 stream<long>::iterator it = s.begin(); 64 for(int i=0; i<n; ++i) ++it; 65 *it; 66 gettimeofday(&tv2, &tz); 67 std::cout<<timeval_diff(tv2, tv1)<<std::endl; 72 68 73 return 0; 69 gettimeofday(&tv1, &tz); 70 fib(n); 71 gettimeofday(&tv2, &tz); 72 std::cout<<timeval_diff(tv2, tv1)<<std::endl; 73 74 return 0; 74 75 }
Note: See TracChangeset
for help on using the changeset viewer.