Index_Core

struct stFileBlock{
    int count;
    char content[512];
};

stHeader{
    int size;
    char *content;
};

struct stBody{
    int size;
    char *content;
};

typedef std::map<std::string,stBody stMemBlockMap;
typedef std::map<std::string,stBody>::iterator stMemBlockIter;
// 写
std::vector<stFileBlock> memBlockToFileBlock(const stMemBlockMap& memBlockMap)
{
    std::vector<stFileBlock> block_vec;
    stFileBlock block;
    char *temp = block.content;
    int curId = 0;
    int eatSize = 0;
    int leftSize = 512;
    int PairSize = 0;
    for (stMemBlockIter pos = memBlockMap.begin(); pos != memBlockMap.end();)
    {
        eatSize = pos->first.size() + pos->sceond.size + sizeof(int) +sizeof(int);
        if (eatSize <= leftSize)
        {
            int size = pos->first.size();
            bcopy(&size,temp + curId,sizeof(int)); // 写头
            curId += sizeof(int);
           
            bcopy(pos->first.c_str(),temp+curId,pos->first.size()); // 写内容
            curId += pos->first.size();
           
            bcopy(&pos->second.size,temp + curId,sizeof(int)); //写头
            curId += sizeof(int);
           
            bcopy(pos->second.content,block.content + curId,pos->sceond.size) // 写内容
            curId += pos->second.size;
           
            leftSize -= eatSize;
            PairSize ++;
            ++pos;
        }
        else
        {
            block.size = PairSize;
            block_vec.push_back(block);
            temp = block.content;
            curId = 0;
            PairSize = 0;
            leftSize = 512;
        }
    }
    if (eatSize <= leftSize + eatSize)
    {
        block_vec.push_back(block);
    }
}

// 读
stMemBlockMap fileBlockVectorToMap(const std::vector<stFileBlock>& blockvec)
{
    stMemBlockMap blockMap;
    for (std::vector<stFileBlock>::iterator pos = blockvec.begin(); pos != blockvec.end();++pos)
    {
        if (pos->count == 0)
        {
            continue;
        }
        else
        {
            int eatSize = 0;
            for(int i = 0;i< pos->count;i++)
            {
                stHeader header = *(stHeader*)(pos->content + eatSize);
                eatSize += sizeof(stHeader);
                stBody  body = *(stBody*)(pos->content + eatSize);
                eatSize += sizeof(stBody);
                std::string key(header.content,header.size);
                blockMap[key] = body;
            }
        }
    }
    return blockMap;
}

void writeToFile(stFileBlock * block,int id)
{
   
}

stFileBlock* readBlockFrom(int id)
{

}

int keyToNum(char *content,int size)
{

}
 

class KVManager{
    std::vector<FILE *hF> fileList;
   
   
};

这个函数的作用 def parser_vim(self): # with open(self.result_path, encoding='utf-8-sig') as f: # print(self.result_path) with open(self.result_path) as f: for index, row in enumerate( csv.reader(f, skipinitialspace=True)): # print(row) # input() if index == 0 : for index,i in enumerate(row): if i == "Target_Dieid": index_die_id = index if self.mode == "core": if i == "Cur Core Freq": index_die_freq = index if self.mode == "uncore": if i == "Cur Uncore Freq": index_die_freq = index if i == "VMIN": index_die_vmin = index continue if len(row) == 0 : continue # print(index_die_id) # print(index_die_freq) # print(index_die_vmin) # input() if "CORE" in row: if row[index_die_freq] not in self.vmin_dict: #判断频点在不在 self.vmin_dict[row[index_die_freq]] = {} if row[index_die_id] == "0": self.vmin_dict[row[index_die_freq]]["DIE0_Core"] = (float(row[index_die_vmin]), self.get_worst_hpm(0,"core") , self.chip_id ) if row[index_die_id] == "1": self.vmin_dict[row[index_die_freq]]["DIE1_Core"] = (float(row[index_die_vmin]), self.get_worst_hpm(1,"core"), self.chip_id) if "UNCORE" in row: if row[index_die_freq] not in self.vmin_dict: self.vmin_dict[row[index_die_freq]] = {} if row[index_die_id] == "0": self.vmin_dict[row[index_die_freq]]["DIE0_UnCore"] = (float(row[index_die_vmin]), self.get_worst_hpm(0,"uncore"), self.chip_id) if row[index_die_id] == "1": self.vmin_dict[row[index_die_freq]]["DIE1_UnCore"] = (float(row[index_die_vmin]), self.get_worst_hpm(1,"uncore"), self.chip_id) # print(self.vmin_dict) # input()
08-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值