<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

void selection_sort(int *, unsigned long);
void imprimir_vetor(int *, unsigned long);

int main(int argc, char *argv[])
{
	struct timeval timevalA;
        struct timeval timevalB;

	int *vetor = NULL;
	unsigned long tam, i = 0;

	if (argc != 2) {
		printf("%s elementos\n", argv[0]);
		exit(EXIT_FAILURE);
	}	
	
	tam = atoi(argv[1]);

	if (!(vetor = (int *) malloc(sizeof(int) * tam))) {
		printf("Erro ao alocar memória\n");
		exit(EXIT_FAILURE);
	}

	srand(time(NULL));		
	for (i = 0; i < tam; i++) {
		*(vetor + i) = random() % 10000;
	}

	gettimeofday(&timevalA, NULL);
	selection_sort(vetor, tam);	
	gettimeofday(&timevalB, NULL);

	printf("%lf\n", timevalB.tv_sec - timevalA.tv_sec + (timevalB.tv_usec - timevalA.tv_usec) / (double) 1000000);

	//imprimir_vetor(vetor, tam);

	free(vetor);
	return EXIT_SUCCESS;
}

void selection_sort(int *vetor, unsigned long tam)
{
	unsigned long i, j, min;
	int aux;
	
	for (i = 0; i < tam - 1; i++) {
		min = i;
		for (j = i + 1; j < tam; j++) {
			if (vetor[j] < vetor[min]) { 
         			min = j;
			}
     		}
		if (vetor[i] != vetor[min]) {
			aux = vetor[i];
			vetor[i] = vetor[min];
			vetor[min] = aux;<commit_msg>inicial change on code, like test loop<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>

void selection_sort(int *, unsigned long, unsigned int);
void imprimir_vetor(int *, unsigned long);
void verify(int *, unsigned long);

int main(int argc, char *argv[])
{
	struct timeval timevalA;
        struct timeval timevalB;

	int *vetor = NULL;
	unsigned long tam, i = 0;
	unsigned int numThread;
	int count;

	if (argc != 3) {
		printf("%s elementos e numero de threads\n", argv[0]);
		exit(EXIT_FAILURE);
	}

	tam = atoi(argv[1]);
	numThread = atoi(argv[2]);

	if (!(vetor = (int *) malloc(sizeof(int) * tam))) {
		printf("Erro ao alocar memória\n");
		exit(EXIT_FAILURE);
	}

	srand(time(NULL));
	for (count = 0; count < 10; count++) {
		for (i = 0; i < tam; i++) {
			*(vetor + i) = random() % 10000;
		}
		gettimeofday(&timevalA, NULL);
		selection_sort(vetor, tam, numThread);
		gettimeofday(&timevalB, NULL);
		verify(vetor,tam);
		printf("%lf\n", timevalB.tv_sec - timevalA.tv_sec + (timevalB.tv_usec - timevalA.tv_usec) / (double) 1000000);

		//imprimir_vetor(vetor, tam);
	}
	free(vetor);
	return EXIT_SUCCESS;
}

void verify(int *vetor, unsigned long tam){
	int x;
	x = vetor[0];
	for (int i = 0; i < tam; i++) {
		if (x > vetor[i]) {
			printf("TA ERRADO MANO\n");
			break;
		}
		x = vetor[i];
	}
}


void selection_sort(int *vetor, unsigned long tam, unsigned int numThread)
{
	unsigned long i, j, min;
	int aux;

	for (i = 0; i < tam - 1; i++) {
		min = i;
		for (j = i + 1; j < tam; j++) {
			if (vetor[j] < vetor[min]) {
         			min = j;
			}
     		}
		if (vetor[i] != vetor[min]) {
			aux = vetor[i];
			vetor[i] = vetor[min];
			vetor[min] = aux;
{'fraction_non_alphanumeric': 0.1780636425186188, 'fraction_numerical': 0.015572105619498984, 'mean_word_length': 3.384272997032641, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4776833', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1223, 'n_words': 309}