Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<vector>
- #include<time.h>
- using namespace std;
- vector<bool> bools;
- vector<char> chars;
- const int N=10000000;
- void test_chars()
- {
- chars.clear();
- double start=clock();
- char tmp=0;
- for(int i=0;i<N;++i)
- {
- chars.push_back((char)(i%2));
- }
- for(int i=0;i<N;++i)
- {
- chars[i],chars[i],chars[i];
- }
- printf("chars: %.4lf\n",(clock()-start)/CLOCKS_PER_SEC);
- }
- void test_bools()
- {
- bools.clear();
- double start=clock();
- for(int i=0;i<N;++i)
- {
- bools.push_back((bool)(i%2));
- }
- for(int i=0;i<N;++i)
- {
- bools[i],bools[i],bools[i];
- }
- printf("bools: %.4lf\n",(clock()-start)/CLOCKS_PER_SEC);
- }
- const bool D=1;
- int main()
- {
- for(int i=0;i<5;++i)
- {
- test_chars();
- test_bools();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement