代码拉取完成,页面将自动刷新
同步操作将从 openEuler/wayca-scheduler 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* Copyright (c) 2021 HiSilicon Technologies Co., Ltd.
* Wayca scheduler is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
*/
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#define MAX_PERF_COUNT 30
#define MAX_NAME_LEN 40
struct perf_count {
char name[MAX_NAME_LEN];
long long value;
} old[MAX_PERF_COUNT], new[MAX_PERF_COUNT];
/*
* TODO: move to perf_event_open() and get counter from kernel
* rather than depending on perf tool
*/
int perf_stat(pid_t pid, int start)
{
int p[2];
pid_t cpid;
#define MAX_LEN 400
char cmd[MAX_LEN];
sprintf(cmd, "perf stat -e branch-misses,bus-cycles,cache-misses,"
"cycles,instructions,stalled-cycles-backend,stalled-cycles-frontend,"
"bus_cycles,mem_access,remote_access,ll_cache,ll_cache_miss"
" -a -p %d -x ' ' -- sleep 5", pid);
if (pipe(p) == -1) {
perror("cannot create the IPC pipe");
return -1;
}
cpid = fork();
if (cpid == -1) {
perror("cannot create new process");
return -1;
} else if (cpid == 0) {
dup2(p[1], STDERR_FILENO);
close(p[0]);
close(p[1]);
execl("/bin/sh", "/bin/sh", "-c", cmd, NULL);
return 0;
} else {
int status;
int i, j;
dup2(p[0], STDIN_FILENO);
close(p[0]);
close(p[1]);
do {
waitpid(cpid, &status, WUNTRACED | WCONTINUED);
} while (!WIFEXITED(status) && !WIFSIGNALED(status));
for (i = 0; i < MAX_PERF_COUNT;) {
int ret;
struct perf_count *perf;
if (start)
perf = old;
else
perf = new;
ret =
scanf("%lld%30s%*[^\n]%*c", &perf[i].value,
perf[i].name);
if (ret >= 2) {
i++;
} else if (ret == 0) {
scanf("%*[^\n]%*c");
} else if (ret == -1) {
clearerr(stdin);
break;
}
}
if (!start) {
printf
("------[Performance changes after deployment]--------------\n");
for (j = 0; j < i; j++) {
float old_ipc, new_ipc;
printf("%-30s %16lld -> %16lld %f%%\n",
old[j].name, old[j].value, new[j].value,
(new[j].value -
old[j].value) * 100.0 / old[j].value);
if (strstr(old[j].name, "instructions")) {
old_ipc =
old[j].value * 1.0 / old[j -
1].value;
new_ipc =
new[j].value * 1.0 / new[j -
1].value;
printf
("%-30s %.4f -> %.4f %f%%\n",
"inst per cycle", old_ipc, new_ipc,
(new_ipc -
old_ipc) * 100.0 / old_ipc);
j++; /* skip stalled cycle */
}
}
printf("------[End]--------------\n");
}
return 0;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。