1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-11 13:06:59 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-12-11 16:52:19 +09:00
parent 3880c4afd0
commit 2bfbdff1b4
2 changed files with 15 additions and 17 deletions

View File

@ -1,15 +1,12 @@
CC=clang
CXX=clang++
LLVM_CONFIG=llvm-project/build/bin/llvm-config
LLVM_TBLGEN=llvm-project/build/bin/llvm-tblgen
LLVM_LIBS=$(wildcard llvm-project/build/lib/libLLVM*.a)
CURRENT_DIR=$(shell pwd)
TBB_LIBDIR=$(wildcard $(CURRENT_DIR)/oneTBB/build/linux_intel64_*_release/)
CPPFLAGS=-g $(shell $(LLVM_CONFIG) --cxxflags) -IoneTBB/include -pthread -std=c++20 -Wno-deprecated-volatile -O2
LDFLAGS=$(shell $(LLVM_CONFIG) --ldflags) -L$(TBB_LIBDIR) -Wl,-rpath=$(TBB_LIBDIR) -fuse-ld=lld
LIBS=-pthread -ltbb -lcurses -Wl,--start-group $(LLVM_LIBS) -Wl,--end-group
CPPFLAGS=-g -IoneTBB/include -pthread -std=c++20 -Wno-deprecated-volatile -O2
LDFLAGS=-L$(TBB_LIBDIR) -Wl,-rpath=$(TBB_LIBDIR) -fuse-ld=lld
LIBS=-pthread -ltbb -lcurses -Wl,--start-group -Wl,--end-group
OBJS=main.o object_file.o input_sections.o output_chunks.o mapfile.o perf.o \
linker_script.o elf.o

23
perf.cc
View File

@ -29,8 +29,8 @@ static u64 now_nsec() {
return (u64)t.tv_sec * 1000000000 + t.tv_nsec;
}
static u64 to_usec(struct timeval t) {
return t.tv_sec * 1000000 + t.tv_usec;
static u64 to_nsec(struct timeval t) {
return t.tv_sec * 1000000000 + t.tv_usec * 1000;
}
Timer::Timer(std::string name) : name(name) {
@ -40,8 +40,8 @@ Timer::Timer(std::string name) : name(name) {
getrusage(RUSAGE_SELF, &usage);
start = now_nsec();
user = to_usec(usage.ru_utime);
sys = to_usec(usage.ru_stime);
user = to_nsec(usage.ru_utime);
sys = to_nsec(usage.ru_stime);
}
void Timer::stop() {
@ -53,13 +53,13 @@ void Timer::stop() {
getrusage(RUSAGE_SELF, &usage);
end = now_nsec();
user = to_usec(usage.ru_utime) - user;
sys = to_usec(usage.ru_stime) - sys;
user = to_nsec(usage.ru_utime) - user;
sys = to_nsec(usage.ru_stime) - sys;
}
void Timer::print() {
for (Timer *t : instances)
t->stop();
for (int i = instances.size() - 1; i >= 0; i--)
instances[i]->stop();
std::vector<int> depth(instances.size());
@ -72,13 +72,14 @@ void Timer::print() {
std::cout << " User System Real Name\n";
for (int i = 0; i < instances.size(); i++) {
Timer &t = *instances[i];;
Timer &t = *instances[i];
printf(" % 8.3f % 8.3f % 8.3f %s%s\n",
((double)t.user / 1000000),
((double)t.sys / 1000000),
((double)t.user / 1000000000),
((double)t.sys / 1000000000),
(((double)t.end - t.start) / 1000000000),
std::string(" ", depth[i]).c_str(),
t.name.c_str());
}
std::cout << std::flush;
}