// File: /workspace/github_cpp_makefile_star2_O1/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 $0x198, %rsp            # imm = 0x198
movq %rdi, %r13
callq 0x4060
movq %rax, 0x20(%rsp)
movslq 0x7c(%r13), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x591c
cmpl $0x0, 0x80(%r13)
jle 0x5147
xorl %eax, %eax
leaq 0x108(%rsp), %r14
leaq 0x40(%rsp), %r12
leaq 0x4(%rsp), %r15
movq %rax, 0x28(%rsp)
movslq 0x7c(%r13), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x5998
cmpl $0x0, 0x7c(%r13)
jle 0x50fb
xorl %ebp, %ebp
xorl %ebx, %ebx
callq 0x43c0
movl %eax, %ecx
movl %ebx, %eax
xorl %edx, %edx
divl %ecx
movl %edx, 0x4(%rsp)
leaq 0x98b(%rip), %rax       # 0x5a10
movq %rax, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
movq %r13, %r14
movq %r13, 0x38(%rsp)
movq 0x8(%rsp), %rax
addq %rbp, %rax
movq %rax, 0x30(%rsp)
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
leaq 0x38(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %r15, %r8
callq 0x5d28
movq 0x108(%rsp), %rax
cmpq $0x0, (%rax,%rbx,8)
jne 0x5793
movq 0xc0(%rsp), %rcx
movq %rcx, (%rax,%rbx,8)
incq %rbx
movq %r14, %r13
movslq 0x7c(%r14), %rax
addq $0x78, %rbp
cmpq %rax, %rbx
jl 0x506d
movq 0x108(%rsp), %rbx
cmpq 0x110(%rsp), %rbx
leaq 0x108(%rsp), %r14
je 0x512b
movq %rbx, %rdi
callq 0x4480
addq $0x8, %rbx
cmpq 0x110(%rsp), %rbx
jne 0x5115
movq %r14, %rdi
callq 0x5dd8
movq 0x28(%rsp), %rax
incl %eax
cmpl 0x80(%r13), %eax
jl 0x504a
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0xb0(%rsp)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
cmpq %rcx, %rax
je 0x51cc
movl $0x14, %edx
movq -0x14(%rax,%rdx), %rsi
addq %rsi, 0x2c(%rsp,%rdx)
movq -0xc(%rax,%rdx), %rsi
addq %rsi, 0x34(%rsp,%rdx)
movl -0x4(%rax,%rdx), %esi
addl %esi, 0x3c(%rsp,%rdx)
movl (%rax,%rdx), %esi
addl %esi, 0x40(%rsp,%rdx)
addq $0x18, %rdx
cmpq $0x8c, %rdx
jne 0x5196
addq $0x78, %rax
jmp 0x518c
movq %r13, %r12
callq 0x4060
subq 0x20(%rsp), %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
imulq %rcx
movq %rdx, %r14
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x10fe3(%rip), %rsi     # 0x161df
leaq 0x10fe2(%rip), %rdx     # 0x161e5
leaq 0xc0(%rsp), %rbp
movq %rbp, %rdi
callq 0x588c
leaq 0xe0(%rsp), %r15
leaq 0xf0(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x10fb8(%rip), %rsi     # 0x161e6
leaq 0x10fb8(%rip), %rdx     # 0x161ed
movq %r15, %rdi
callq 0x588c
movq 0x1ad64(%rip), %rdi     # 0x1ffa8
leaq 0x10fa3(%rip), %rsi     # 0x161ee
movl $0xb, %edx
callq 0x4370
movslq 0x78(%r12), %rax
shlq $0x5, %rax
movq 0xc0(%rsp,%rax), %rsi
movq 0xc8(%rsp,%rax), %rdx
movq 0x1ad33(%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 0x1acfd(%rip), %rdi     # 0x1ffa8
leaq 0x10f48(%rip), %rsi     # 0x161fa
movl $0x13, %edx
callq 0x4370
movl 0x7c(%r12), %esi
movq 0x1ace0(%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 0x1acaa(%rip), %rdi     # 0x1ffa8
leaq 0x10f09(%rip), %rsi     # 0x1620e
movl $0x11, %edx
callq 0x4370
movl 0x80(%r12), %esi
movq 0x1ac8a(%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 0x1ac54(%rip), %rdi     # 0x1ffa8
leaq 0x10ec5(%rip), %rsi     # 0x16220
movl $0x12, %edx
callq 0x4370
movq %r14, %rax
shrq $0x3f, %rax
sarq $0x12, %r14
addq %rax, %r14
movq 0x1ac2e(%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 0x1abf5(%rip), %rdi     # 0x1ffa8
leaq 0x10e79(%rip), %rsi     # 0x16233
movl $0x1c, %edx
callq 0x4370
callq 0x43c0
movl %eax, %esi
movq 0x1abd6(%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 0x108(%rsp), %rsi
xorl %edi, %edi
callq 0x41c0
movq 0x1ab91(%rip), %rdi     # 0x1ffa8
leaq 0x10e32(%rip), %rsi     # 0x16250
movl $0x1f, %edx
callq 0x4370
movq 0x128(%rsp), %rsi
movq 0x1ab71(%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 0x10dd8(%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 0x10da5(%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 0x10d69(%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 0x10d34(%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 0x10cfa(%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 0x1a9f9(%rip), %r14     # 0x1ffa8
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4230
xorl %r15d, %r15d
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 (%r12,%r15), %rbx
testq %rbx, %rbx
je 0x560b
movq %rbx, %rdi
callq 0x4130
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4370
jmp 0x5620
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 0x50(%rsp,%r15), %rbx
testq %rbx, %rbx
je 0x565f
movq 0x40(%rsp,%r15), %rax
xorl %edx, %edx
divq %rbx
movq %rax, %rsi
jmp 0x5661
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 0x54(%rsp,%r15), %rbx
testq %rbx, %rbx
je 0x56d7
movq 0x48(%rsp,%r15), %rax
xorl %edx, %edx
divq %rbx
movq %rax, %rsi
jmp 0x56d9
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, %r15
cmpq $0x78, %r15
jne 0x55c7
movq $-0x40, %rbx
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0x5760
movq (%r13), %rsi
incq %rsi
callq 0x4310
addq $-0x20, %r13
addq $0x20, %rbx
jne 0x574b
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5781
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x4310
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4080
movq %rax, %rbx
jmp 0x57a3
movq %rax, %rbx
movq %rbp, %r15
cmpq %r15, %rbp
je 0x5823
addq $-0x10, %r15
leaq 0xc0(%rsp), %r14
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x57c8
movq (%r15), %rsi
incq %rsi
callq 0x4310
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x57b4
jmp 0x5823
jmp 0x57e3
movq %rax, %rbx
jmp 0x5823
jmp 0x57e3
movq %rax, %rbx
xorl %r14d, %r14d
movq 0xe0(%rsp,%r14), %rdi
leaq (%r14,%r13), %rax
cmpq %rdi, %rax
je 0x5805
movq (%rax), %rsi
incq %rsi
callq 0x4310
addq $-0x20, %r14
cmpq $-0x40, %r14
jne 0x57e9
jmp 0x5823
jmp 0x5813
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x5dd8
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x583a
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x4310
movq %rbx, %rdi
callq 0x44d0