<commit_before>/* timing.c
** - Timing functions
*/

#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>

#ifdef _WIN32
#include <mmsystem.h>
#endif

#include "timing.h"

/* 
 * Returns milliseconds no matter what. 
 */
uint64_t timing_get_time(void)
{
#ifdef _WIN32
	return timeGetTime();
#else 
	struct timeval mtv;

	gettimeofday(&mtv, NULL);

	return (uint64_t)(mtv.tv_sec) * 1000 + (uint64_t)(mtv.tv_usec) / 1000;
#endif
}

void timing_sleep(uint64_t sleeptime)
{
	struct timeval sleeper;

	sleeper.tv_sec = 0;
	sleeper.tv_usec = sleeptime * 1000;

	select(1, NULL, NULL, NULL, &sleeper);
}
<commit_msg>select first argument should be 0 when we use it for sleeping.<commit_after>/* timing.c
** - Timing functions
*/

#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>

#ifdef _WIN32
#include <mmsystem.h>
#endif

#include "timing.h"

/* 
 * Returns milliseconds no matter what. 
 */
uint64_t timing_get_time(void)
{
#ifdef _WIN32
	return timeGetTime();
#else 
	struct timeval mtv;

	gettimeofday(&mtv, NULL);

	return (uint64_t)(mtv.tv_sec) * 1000 + (uint64_t)(mtv.tv_usec) / 1000;
#endif
}

void timing_sleep(uint64_t sleeptime)
{
	struct timeval sleeper;

	sleeper.tv_sec = 0;
	sleeper.tv_usec = sleeptime * 1000;

	/* NOTE:
	 * This should be 0 for the first argument.  The linux manpage
	 * says so.  The solaris manpage also says this is a legal
	 * value.  If you think differerntly, please provide references.
	 */
	select(0, NULL, NULL, NULL, &sleeper);
}

{'fraction_non_alphanumeric': 0.13451776649746192, 'fraction_numerical': 0.03426395939086294, 'mean_word_length': 4.170491803278688, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '2599368', 'n_tokens_mistral': 690, 'n_tokens_neox': 622, 'n_words': 162}