Skip to content

Instantly share code, notes, and snippets.

@mactkg
Created July 9, 2012 13:27
Show Gist options
  • Save mactkg/3076555 to your computer and use it in GitHub Desktop.
Save mactkg/3076555 to your computer and use it in GitHub Desktop.
はいれつ
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <limits.h>
#define NUM 100000
#define N 2147483647L
int main(void){
long long int i;
clock_t start,end;
char a[NUM];
char b[NUM/100];
for(i = 0; i < NUM; i++)
a[i] = 'a';
for(i = 0; i < NUM/100; i++)
b[i] = 'b';
start = clock();
for(i = 0; i < N; i++)
strlen(a);
end = clock();
printf("a:%.20f\n", (double)(end-start));
start = clock();
for(i = 0; i < N; i++)
strlen(b);
end = clock();
printf("b:%.20f\n", (double)(end-start));
}
@mactkg
Copy link
Author

mactkg commented Jul 9, 2012

a:5466927.00000000000000000000
b:5391424.00000000000000000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment