mirror of
https://gitee.com/openharmony/developtools_hiperf
synced 2024-11-23 07:29:42 +00:00
!519 按照CFI指导修改hiperf中std::bind和std::thread为匿名函数用法
Merge pull request !519 from jiangwei/master
This commit is contained in:
commit
a15e8e9246
@ -69,7 +69,10 @@ int main()
|
||||
if (myHiperf.Start(opt)) {
|
||||
printf("demo start successfully\n");
|
||||
}
|
||||
std::thread workload(TestCodeThread, 0);
|
||||
auto it = []() {
|
||||
TestCodeThread(0);
|
||||
}
|
||||
std::thread workload(it);
|
||||
sleep(waitTime);
|
||||
// try for each thread times
|
||||
for (int i = 0; i < countTry; i++) {
|
||||
|
@ -121,7 +121,9 @@ void Report::StatisticsRecords()
|
||||
// merge duplicate
|
||||
HLOGD("uniquing %zu", totalReportCount);
|
||||
auto last = std::unique(config.reportItems_.begin(), config.reportItems_.end(),
|
||||
std::bind(&Report::MultiLevelSameAndUpdateCount, this, _1, _2));
|
||||
[this] (ReportItem &l, ReportItem &r) -> bool {
|
||||
return this->MultiLevelSameAndUpdateCount(l, r);
|
||||
});
|
||||
|
||||
config.reportItems_.erase(last, config.reportItems_.end());
|
||||
|
||||
@ -196,7 +198,9 @@ void Report::AdjustReportItems()
|
||||
// sort first.
|
||||
HLOGD("MultiLevelSorting %" PRIu64 "", totalReportCount);
|
||||
std::sort(config.reportItems_.begin(), config.reportItems_.end(),
|
||||
std::bind(&Report::MultiLevelSorting, this, _1, _2));
|
||||
[this] (const ReportItem &a, const ReportItem &b) -> bool {
|
||||
return this->MultiLevelSorting(a, b);
|
||||
});
|
||||
HLOGD("MultiLevelSorting %" PRIu64 " done", totalReportCount);
|
||||
// reorder the callstack
|
||||
if (option_.debug_) {
|
||||
|
@ -774,7 +774,9 @@ void SubCommandRecord::RecoverSavedCmdlinesSize()
|
||||
bool SubCommandRecord::PreparePerfEvent()
|
||||
{
|
||||
// we need to notify perfEvents_ sampling mode by SetRecordCallBack first
|
||||
auto processRecord = std::bind(&SubCommandRecord::ProcessRecord, this, std::placeholders::_1);
|
||||
auto processRecord = [this](std::unique_ptr<PerfEventRecord> record) -> bool {
|
||||
return this->ProcessRecord(std::move(record));
|
||||
};
|
||||
perfEvents_.SetRecordCallBack(processRecord);
|
||||
|
||||
perfEvents_.SetCpu(selectCpus_);
|
||||
@ -873,7 +875,9 @@ bool SubCommandRecord::PrepareSysKernel()
|
||||
|
||||
bool SubCommandRecord::PrepareVirtualRuntime()
|
||||
{
|
||||
auto saveRecord = std::bind(&SubCommandRecord::SaveRecord, this, std::placeholders::_1, false);
|
||||
auto saveRecord = [this](std::unique_ptr<PerfEventRecord> record) -> bool {
|
||||
return this->SaveRecord(std::move(record), false);
|
||||
};
|
||||
virtualRuntime_.SetRecordMode(saveRecord);
|
||||
|
||||
// do some config for virtualRuntime_
|
||||
@ -906,8 +910,9 @@ bool SubCommandRecord::PrepareVirtualRuntime()
|
||||
}
|
||||
if (dedupStack_) {
|
||||
virtualRuntime_.SetDedupStack();
|
||||
auto collectSymbol =
|
||||
std::bind(&SubCommandRecord::CollectSymbol, this, std::placeholders::_1);
|
||||
auto collectSymbol = [this](PerfRecordSample *sample) {
|
||||
this->CollectSymbol(std::move(sample));
|
||||
};
|
||||
virtualRuntime_.SetCollectSymbolCallBack(collectSymbol);
|
||||
}
|
||||
return true;
|
||||
@ -1713,7 +1718,9 @@ bool SubCommandRecord::FinishWriteRecordFile()
|
||||
virtualRuntime_.CollectDedupSymbol(kernelSymbolsHits_, userSymbolsHits_);
|
||||
} else {
|
||||
fileWriter_->ReadDataSection(
|
||||
std::bind(&SubCommandRecord::CollectionSymbol, this, std::placeholders::_1));
|
||||
[this] (std::unique_ptr<PerfEventRecord> record) -> bool {
|
||||
return this->CollectionSymbol(std::move(record));
|
||||
});
|
||||
}
|
||||
#if USE_COLLECT_SYMBOLIC
|
||||
SymbolicHits();
|
||||
|
@ -482,7 +482,9 @@ bool SubCommandReport::LoadPerfData()
|
||||
// before load data section
|
||||
SetHM();
|
||||
recordFileReader_->ReadDataSection(
|
||||
std::bind(&SubCommandReport::RecordCallBack, this, std::placeholders::_1));
|
||||
[this] (std::unique_ptr<PerfEventRecord> record) -> bool {
|
||||
return this->RecordCallBack(std::move(record));
|
||||
});
|
||||
if (cpuOffMode_) {
|
||||
FlushCacheRecord();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user