c
#include <iostream>
using namespace std;
uint8_t *st_point[4];
uint8_t *ed_point[4];
#define THREAD_NUMS 10
void calc_thread_range(uint8_t *buf, uint64_t length, uint8_t *st_point[THREAD_NUMS], uint8_t *ed_point[THREAD_NUMS])
{
int i = 0;
int cur_pos = 0;
int pos_record[THREAD_NUMS + 2] = {0};
pos_record[0] = 0;
for(i = 0; i < THREAD_NUMS; i++)
{
cur_pos = length / THREAD_NUMS * (i + 1);
while(buf[cur_pos] != '\n')
{
cur_pos--;
}
pos_record[i + 1] = cur_pos;
}
pos_record[THREAD_NUMS + 1] = length;
}
int main()
{
char buf[1024] = {0};
clock_t start = 0, finish = 0;
start = clock();
int i = 0;
FILE *f = fopen("test.txt", "rb");
fseek(f, 0, SEEK_END);
long size = ftell(f);
fseek(f, 0, SEEK_SET);
uint8_t *buf_heap = new uint8_t[size];
fread(buf_heap, 1, size, f);
calc_thread_range(buf_heap, size, st_point, ed_point);
// while (!feof(f)) {
// i++;
// fscanf(f, "%s", buf);
// }
fclose(f);
finish = clock();
cout << i << endl;
cout << finish - start << endl;
cout << "Hello World!" << endl;
return 0;
}