#include <stdio.h>
#include <string.h>
#include <locale.h>
#include <sys/time.h>

#define ITERATIONS 1000000000
#define THE_LOCALE "en_US.UTF-8"

int main(int argc, char *argv[]) {
	int i;
	char buff11[256];
	char buff12[256];
	char *buff21;
	char *buff22;
	char *str1 = "abcdefghijklmnop1";
	char *str2 = "abcdefghijklmnop2";
	char *newlocale;
	struct timeval t1,t2,t3;
	int elapsed_strcmp,elapsed_strcoll;

	int len1 = strlen(str1);
	int len2 = strlen(str2);
	if( (newlocale = setlocale(LC_ALL,THE_LOCALE)) == NULL ) {
		printf("error setting locale!\n");
		exit(1);
	} 
	else {
		printf("locale set to: %s\n",newlocale);
	}
	
	gettimeofday(&t1,NULL);
	for(i=0; i < ITERATIONS; i++) {
		strcmp(str1,str2);
	}
	gettimeofday(&t2,NULL);
	for(i=0; i < ITERATIONS; i++) {
		strcoll(str1,str2);
	}
	gettimeofday(&t3,NULL);
	elapsed_strcmp = (t2.tv_sec * 1000000 + t2.tv_usec) - (t1.tv_sec * 1000000 + t1.tv_usec);
	elapsed_strcoll = (t3.tv_sec * 1000000 + t3.tv_usec) - (t2.tv_sec * 1000000 + t2.tv_usec);
	printf("strcmp time elapsed:  %d us\n",elapsed_strcmp);
	printf("strcoll time elapsed: %d us\n",elapsed_strcoll);

}
