<commit_before>#include "lthread.h"
#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>

void a(void *x);
char line[] = "this is an lthread io test\n";

void
a(void *arg)
{
	int i, x;
    i = x = 3000;
	struct timeval t1 = {0, 0};
	struct timeval t2 = {0, 0};
    lthread_detach();
    int fd = 0;
    double total = 0;

    fd = open("/tmp/lthread_io.txt", O_CREAT | O_APPEND | O_WRONLY, 0640);
	while (i--) {
		gettimeofday(&t1, NULL);
		write(fd, line, sizeof(line));
		gettimeofday(&t2, NULL);
        total += ((t2.tv_sec * 1000.0) + t2.tv_usec /1000.0) -
             ((t1.tv_sec * 1000.0) + t1.tv_usec/1000.0);

	}
	printf("io_write took %lf msec (avg: %lf) to write %d lines\n", total, total / (double)x, x);
}


int
main(int argc, char **argv)
{
	lthread_t *lt = NULL;

	lthread_create(&lt, a, NULL);
	lthread_run();
<commit_msg>fix lthread_io unit test<commit_after>#include "lthread.h"
#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>

void a(void *x);
char line[] = "this is an lthread io test\n";

void
a(void *arg)
{
	int i, x;
    i = x = 3000;
	struct timeval t1 = {0, 0};
	struct timeval t2 = {0, 0};
    lthread_detach();
    int fd = 0;
    double total = 0;

    fd = open("/tmp/lthread_io.txt", O_CREAT | O_APPEND | O_WRONLY, 0640);
	while (i--) {
		gettimeofday(&t1, NULL);
		lthread_io_write(fd, line, sizeof(line));
		gettimeofday(&t2, NULL);
        total += ((t2.tv_sec * 1000.0) + t2.tv_usec /1000.0) -
             ((t1.tv_sec * 1000.0) + t1.tv_usec/1000.0);

	}
	printf("io_write took %lf msec (avg: %lf) to write %d lines\n", total, total / (double)x, x);
}


int
main(int argc, char **argv)
{
	lthread_t *lt = NULL;

	lthread_create(&lt, a, NULL);
	lthread_run();

{'fraction_non_alphanumeric': 0.18181818181818182, 'fraction_numerical': 0.04895104895104895, 'mean_word_length': 3.1674757281553396, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1831212', 'n_tokens_mistral': 814, 'n_tokens_neox': 745, 'n_words': 191}