// File: /workspace/github_cpp_makefile_star2_O3/walker-xian[P]teisye/heapperf/heapperf.cpp
// Function: application::run()
void run()
    {
        auto start_time{ high_resolution_clock::now() };

        vector<case_statistics_t> tcs(_num_of_threads);
        for (int l = 0; l < _num_of_loops; ++l)
        {
            vector<thread> threads(_num_of_threads);

            for (int i = 0; i < _num_of_threads; ++i)
            {
				int core = i % thread::hardware_concurrency();
                thread t{ &application::test,  this, std::ref(tcs[i]), core };
                threads[i] = move(t);
            }

            // wait for all threads have completed
            for (auto it = threads.begin(); it != threads.end(); ++it)
            {
                it->join();
            }
        }

        case_statistics_t final_results;
        for (auto it = tcs.begin(); it != tcs.end(); ++it)
        {
            for (int i = 0; i < _test_case_count; ++i)
                final_results[i] += (*it)[i];
        }

        auto run_duration = duration_cast<milliseconds>(high_resolution_clock::now() - start_time);

        string allocator_names[] { "malloc", "tsalloc"};
        cout << "allocator: " << allocator_names[_allocator_id] << endl;
        cout << "number of threads: " << _num_of_threads << endl;
        cout << "number of loops: " << _num_of_loops << endl;
        cout << "run duration(ms): " << run_duration.count() << endl;
        cout << "number of logic processors: " << thread::hardware_concurrency() << endl;

#if defined(_WIN32) 
#if defined(_MSC_VER)
        PROCESS_MEMORY_COUNTERS_EX pmcex = { 0 };
        GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmcex, sizeof(pmcex));
        cout << "peak working set(KB): " << pmcex.PeakWorkingSetSize / 1024 << endl;
        cout << "private usage(KB): " << pmcex.PrivateUsage / 1024 << endl;
#endif
#else
        rusage ru;
        getrusage(RUSAGE_SELF, &ru);
        cout << "maximum resident set size(KB): " << ru.ru_maxrss << endl;
#endif

        cout << left << setw(12) << "CASE"
             << right << setw(8)  << "AT"        // average allocation cost
             << right << setw(16) << "AC"
             << right << setw(16) << "DT"
             << right << setw(16) << "DC"
             << endl;

        for (int i = 0; i < _test_case_count; ++i)
        {
            cout << left << setw(12) << _test_cases[i]._name
                 << right << setw(8)  << final_results[i].average_allocation_cost()
                 << right << setw(16) << final_results[i]._num_of_allocations
                 << right << setw(16) << final_results[i].average_deallocation_cost()
                 << right << setw(16) << final_results[i]._num_of_deallocations
                 << endl;
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %r13
callq 0x4060
movq %rax, 0x20(%rsp)
movslq 0x7c(%r13), %rsi
leaq 0x8(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0x58e2
cmpl $0x0, 0x80(%r13)
jle 0x511e
xorl %eax, %eax
leaq 0xf8(%rsp), %r14
leaq 0x80(%rsp), %r12
leaq 0x4(%rsp), %r15
movq %rax, 0x28(%rsp)
movslq 0x7c(%r13), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x595c
cmpl $0x0, 0x7c(%r13)
jle 0x50d2
xorl %ebp, %ebp
xorl %ebx, %ebx
callq 0x43c0
movl %eax, %ecx
movl %ebx, %eax
xorl %edx, %edx
divl %ecx
movl %edx, 0x4(%rsp)
leaq 0x96e(%rip), %rax       # 0x59ca
movq %rax, 0x80(%rsp)
movq $0x0, 0x88(%rsp)
movq %r13, %r14
movq %r13, 0x38(%rsp)
movq 0x8(%rsp), %rax
addq %rbp, %rax
movq %rax, 0x30(%rsp)
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
leaq 0x38(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %r15, %r8
callq 0x5ce4
movq 0xf8(%rsp), %rax
cmpq $0x0, (%rax,%rbx,8)
jne 0x577b
movq 0x40(%rsp), %rcx
movq %rcx, (%rax,%rbx,8)
incq %rbx
movq %r14, %r13
movslq 0x7c(%r14), %rax
addq $0x78, %rbp
cmpq %rax, %rbx
jl 0x5044
movq 0xf8(%rsp), %rbx
cmpq 0x100(%rsp), %rbx
leaq 0xf8(%rsp), %r14
je 0x5102
movq %rbx, %rdi
callq 0x4480
addq $0x8, %rbx
cmpq 0x100(%rsp), %rbx
jne 0x50ec
movq %r14, %rdi
callq 0x5d82
movq 0x28(%rsp), %rax
incl %eax
cmpl 0x80(%r13), %eax
jl 0x5021
pxor %xmm0, %xmm0
movdqa %xmm0, 0xe0(%rsp)
movdqa %xmm0, 0xd0(%rsp)
movdqa %xmm0, 0xc0(%rsp)
movdqa %xmm0, 0xb0(%rsp)
movdqa %xmm0, 0xa0(%rsp)
movdqa %xmm0, 0x90(%rsp)
movdqa %xmm0, 0x80(%rsp)
movq $0x0, 0xf0(%rsp)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
cmpq %rcx, %rax
je 0x51c5
movl $0x10, %edx
movdqu -0x10(%rax,%rdx), %xmm0
movdqu 0x70(%rsp,%rdx), %xmm1
paddq %xmm0, %xmm1
movdqu %xmm1, 0x70(%rsp,%rdx)
movq (%rax,%rdx), %xmm0
movq 0x80(%rsp,%rdx), %xmm1
paddd %xmm0, %xmm1
movq %xmm1, 0x80(%rsp,%rdx)
addq $0x18, %rdx
cmpq $0x88, %rdx
jne 0x5181
addq $0x78, %rax
jmp 0x5177
callq 0x4060
subq 0x20(%rsp), %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
imulq %rcx
movq %rdx, %r14
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x10fef(%rip), %rsi     # 0x161df
leaq 0x10fee(%rip), %rdx     # 0x161e5
leaq 0x40(%rsp), %rdi
callq 0x584c
leaq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10fd0(%rip), %rsi     # 0x161e6
leaq 0x10fd0(%rip), %rdx     # 0x161ed
callq 0x584c
movq 0x1ad7f(%rip), %rdi     # 0x1ffa8
leaq 0x10fbe(%rip), %rsi     # 0x161ee
movl $0xb, %edx
callq 0x4370
movslq 0x78(%r13), %rax
shlq $0x5, %rax
movq 0x40(%rsp,%rax), %rsi
movq 0x48(%rsp,%rax), %rdx
movq 0x1ad55(%rip), %rdi     # 0x1ffa8
callq 0x4370
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4230
movq 0x1ad1f(%rip), %rdi     # 0x1ffa8
leaq 0x10f6a(%rip), %rsi     # 0x161fa
movl $0x13, %edx
callq 0x4370
movl 0x7c(%r13), %esi
movq 0x1ad03(%rip), %rdi     # 0x1ffa8
callq 0x44a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4230
movq 0x1accd(%rip), %rdi     # 0x1ffa8
leaq 0x10f2c(%rip), %rsi     # 0x1620e
movl $0x11, %edx
callq 0x4370
movl 0x80(%r13), %esi
movq 0x1acae(%rip), %rdi     # 0x1ffa8
callq 0x44a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4230
movq 0x1ac78(%rip), %rdi     # 0x1ffa8
leaq 0x10ee9(%rip), %rsi     # 0x16220
movl $0x12, %edx
callq 0x4370
movq %r14, %rax
shrq $0x3f, %rax
sarq $0x12, %r14
addq %rax, %r14
movq 0x1ac52(%rip), %rdi     # 0x1ffa8
movq %r14, %rsi
callq 0x42e0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4230
movq 0x1ac19(%rip), %rdi     # 0x1ffa8
leaq 0x10e9d(%rip), %rsi     # 0x16233
movl $0x1c, %edx
callq 0x4370
callq 0x43c0
movl %eax, %esi
movq 0x1abfa(%rip), %rdi     # 0x1ffa8
callq 0x4220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4230
leaq 0xf8(%rsp), %rsi
xorl %edi, %edi
callq 0x41c0
movq 0x1abb5(%rip), %rdi     # 0x1ffa8
leaq 0x10e56(%rip), %rsi     # 0x16250
movl $0x1f, %edx
callq 0x4370
movq 0x118(%rsp), %rsi
movq 0x1ab95(%rip), %r14     # 0x1ffa8
movq %r14, %rdi
callq 0x42e0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4230
movq (%r14), %rax
movq -0x18(%rax), %rcx
movl $0xffffff4f, %ebx       # imm = 0xFFFFFF4F
movl 0x18(%r14,%rcx), %edx
andl %ebx, %edx
orl $0x20, %edx
movl %edx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rax
movq $0xc, 0x10(%r14,%rax)
leaq 0x10dfc(%rip), %rsi     # 0x16270
movl $0x4, %edx
movq %r14, %rdi
callq 0x4370
movq (%r14), %rax
movq -0x18(%rax), %rcx
andl 0x18(%r14,%rcx), %ebx
orl $0x80, %ebx
movl %ebx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rax
movq $0x8, 0x10(%r14,%rax)
leaq 0x10dc9(%rip), %rsi     # 0x16275
movl $0x2, %edx
movq %r14, %rdi
callq 0x4370
movq (%r14), %rax
movq -0x18(%rax), %rcx
movl $0xffffff4f, %ebx       # imm = 0xFFFFFF4F
movl 0x18(%r14,%rcx), %edx
andl %ebx, %edx
orl $0x80, %edx
movl %edx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rax
movq $0x10, 0x10(%r14,%rax)
leaq 0x10d8d(%rip), %rsi     # 0x16278
movl $0x2, %edx
movq %r14, %rdi
callq 0x4370
movq (%r14), %rax
movq -0x18(%rax), %rcx
andl 0x18(%r14,%rcx), %ebx
orl $0x80, %ebx
movl %ebx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rax
movq $0x10, 0x10(%r14,%rax)
leaq 0x10d58(%rip), %rsi     # 0x1627b
movl $0x2, %edx
movq %r14, %rdi
callq 0x4370
movq (%r14), %rax
movq -0x18(%rax), %rcx
movl $0xffffff4f, %edx       # imm = 0xFFFFFF4F
andl 0x18(%r14,%rcx), %edx
orl $0x80, %edx
movl %edx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rax
movq $0x10, 0x10(%r14,%rax)
leaq 0x10d1e(%rip), %rsi     # 0x1627e
movl $0x2, %edx
movq %r14, %rdi
callq 0x4370
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq 0x1aa1d(%rip), %r14     # 0x1ffa8
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4230
xorl %r12d, %r12d
movl $0xffffff4f, %ebp       # imm = 0xFFFFFF4F
movq (%r14), %rax
movq -0x18(%rax), %rcx
movl 0x18(%r14,%rcx), %edx
andl %ebp, %edx
orl $0x20, %edx
movl %edx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rcx
movq $0xc, 0x10(%r14,%rcx)
movq (%r13,%r12), %rbx
testq %rbx, %rbx
je 0x55e8
movq %rbx, %rdi
callq 0x4130
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4370
jmp 0x55fd
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x4470
movq (%r14), %rax
movq -0x18(%rax), %rcx
movl 0x18(%r14,%rcx), %edx
andl %ebp, %edx
orl $0x80, %edx
movl %edx, 0x18(%r14,%rcx)
movq -0x18(%rax), %rax
movq $0x8, 0x10(%r14,%rax)
movslq 0x90(%rsp,%r12), %rbx
testq %rbx, %rbx
je 0x5642
movq 0x80(%rsp,%r12), %rax
xorl %edx, %edx
divq %rbx
movq %rax, %rsi
jmp 0x5644
xorl %esi, %esi
movq %r14, %rdi
callq 0x4220
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movl 0x18(%rax,%rdx), %esi
andl %ebp, %esi
orl $0x80, %esi
movl %esi, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x10, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %ebx, %esi
callq 0x44a0
movq %rax, %rdi
movq (%rax), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rdi,%rcx), %edx
andl %ebp, %edx
orl $0x80, %edx
movl %edx, 0x18(%rdi,%rcx)
movq -0x18(%rax), %rax
movq $0x10, 0x10(%rdi,%rax)
movslq 0x94(%rsp,%r12), %rbx
testq %rbx, %rbx
je 0x56c0
movq 0x88(%rsp,%r12), %rax
xorl %edx, %edx
divq %rbx
movq %rax, %rsi
jmp 0x56c2
xorl %esi, %esi
callq 0x4220
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movl 0x18(%rax,%rdx), %esi
andl %ebp, %esi
orl $0x80, %esi
movl %esi, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x10, 0x10(%rax,%rcx)
movq %rax, %rdi
movl %ebx, %esi
callq 0x44a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4230
addq $0x18, %r12
cmpq $0x78, %r12
jne 0x55a3
movq $-0x40, %rbx
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x5748
movq (%r15), %rsi
incq %rsi
callq 0x4310
addq $-0x20, %r15
addq $0x20, %rbx
jne 0x5734
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5769
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x4310
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4080
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x57e4
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4310
jmp 0x57e4
jmp 0x57a0
jmp 0x57a7
movq %rax, %rbx
jmp 0x57e4
jmp 0x57a7
movq %rax, %rbx
xorl %r14d, %r14d
movq 0x60(%rsp,%r14), %rdi
leaq (%r15,%r14), %rax
cmpq %rdi, %rax
je 0x57c6
movq (%rax), %rsi
incq %rsi
callq 0x4310
addq $-0x20, %r14
cmpq $-0x40, %r14
jne 0x57ad
jmp 0x57e4
jmp 0x57d4
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x5d82
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x57fb
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x4310
movq %rbx, %rdi
callq 0x44d0