[图像Debug工具]多线程任务分发

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;
}
相关推荐
颜酱10 小时前
图的数据结构:从「多叉树」到存储与遍历
javascript·后端·算法
saltymilk15 小时前
使用 C++ 模拟 ShaderLanguage 的 swizzle
c++·模板元编程
zone773915 小时前
006:RAG 入门-面试官问你,RAG 为什么要切块?
后端·算法·面试
CoovallyAIHub18 小时前
OpenClaw 近 2000 个 Skills,为什么没有一个好用的视觉检测工具?
深度学习·算法·计算机视觉
CoovallyAIHub18 小时前
CVPR 2026 | 用一句话告诉 AI 分割什么——MedCLIPSeg 让医学图像分割不再需要海量标注
深度学习·算法·计算机视觉
CoovallyAIHub18 小时前
Claude Code 突然变成了 66 个专家?这个 5.8k Star 的开源项目,让我重新理解了什么叫"会用 AI"
深度学习·算法·计算机视觉
兆子龙18 小时前
前端哨兵模式(Sentinel Pattern):优雅实现无限滚动加载
前端·javascript·算法
xlp666hub21 小时前
Leetcode第五题:用C++解决盛最多水的容器问题
linux·c++·leetcode
CoovallyAIHub1 天前
9个视觉语言模型工厂实测:Qwen 87.9%碾压全场,你的显卡能跑哪个?
算法
SparkX开源AI知识库1 天前
手摸手带你安装OpenClaw并对接飞书
算法·架构