// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %rbp
callq 0x4050
movq %rax, 0x20(%rsp)
movslq 0x7c(%rbp), %rsi
leaq 0x38(%rsp), %rdi
leaq 0x118(%rsp), %r14
movq %r14, %rdx
callq 0x52a4
xorl %eax, %eax
leaq 0xd0(%rsp), %r13
leaq 0xc(%rsp), %r15
movq %rbp, 0x10(%rsp)
cmpl 0x80(%rbp), %eax
jge 0x4c0f
movq %rax, 0x28(%rsp)
movslq 0x7c(%rbp), %rsi
movq %r14, %rdi
leaq 0x50(%rsp), %rdx
callq 0x52f6
xorl %r12d, %r12d
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0x10(%rsp), %rbp
movslq 0x7c(%rbp), %rax
cmpq %rax, %rbx
jge 0x4bd3
callq 0x43c0
movl %eax, %ecx
movl %ebx, %eax
xorl %edx, %edx
divl %ecx
movl %edx, 0xc(%rsp)
leaq 0x7d7(%rip), %rax       # 0x5348
movq %rax, 0x50(%rsp)
andq $0x0, 0x58(%rsp)
movq %rbp, 0x18(%rsp)
movq 0x38(%rsp), %rax
addq %r14, %rax
movq %rax, 0x30(%rsp)
movq %r13, %rdi
leaq 0x50(%rsp), %rsi
leaq 0x18(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %r15, %r8
callq 0x5608
movq 0x118(%rsp), %rdi
addq %r12, %rdi
movq %r13, %rsi
callq 0x56a2
movq %r13, %rdi
callq 0x56bc
incq %rbx
addq $0x78, %r14
addq $0x8, %r12
jmp 0x4b4b
movq 0x118(%rsp), %rbx
leaq 0x118(%rsp), %r14
cmpq 0x120(%rsp), %rbx
je 0x4bfb
movq %rbx, %rdi
callq 0x4460
addq $0x8, %rbx
jmp 0x4be3
movq %r14, %rdi
callq 0x56ca
movq 0x28(%rsp), %rax
incl %eax
jmp 0x4b21
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
andq $0x0, 0xc0(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movq 0x38(%rsp), %r14
leaq 0x118(%rsp), %rbx
cmpq 0x40(%rsp), %r14
je 0x4c87
xorl %r15d, %r15d
cmpq $0x78, %r15
je 0x4c81
leaq (%r14,%r15), %rdx
leaq (%rsp,%r15), %rsi
addq $0x50, %rsi
movq %rbx, %rdi
callq 0x56ec
addq $0x18, %r15
jmp 0x4c61
addq $0x78, %r14
jmp 0x4c57
callq 0x4050
subq 0x20(%rsp), %rax
movl $0xf4240, %ecx          # imm = 0xF4240
cqto
idivq %rcx
movq %rax, %r14
leaq 0xf53a(%rip), %rsi      # 0x141df
leaq 0xd0(%rsp), %rdi
leaq 0x118(%rsp), %rdx
callq 0x50e8
leaq 0xf0(%rsp), %rdi
leaq 0xf51d(%rip), %rsi      # 0x141e6
leaq 0x18(%rsp), %rdx
callq 0x50e8
movq 0x1c2c6(%rip), %rdi     # 0x20fa0
leaq 0xf50d(%rip), %rsi      # 0x141ee
callq 0x4300
movslq 0x78(%rbp), %rcx
shlq $0x5, %rcx
leaq (%rsp,%rcx), %rsi
addq $0xd0, %rsi
movq %rax, %rdi
callq 0x42b0
movq %rax, %rdi
callq 0x4170
movq 0x1c290(%rip), %rdi     # 0x20fa0
leaq 0xf4e3(%rip), %rsi      # 0x141fa
callq 0x4300
movl 0x7c(%rbp), %esi
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
callq 0x4170
movq 0x1c26a(%rip), %rdi     # 0x20fa0
leaq 0xf4d1(%rip), %rsi      # 0x1420e
callq 0x4300
movl 0x80(%rbp), %esi
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
callq 0x4170
movq 0x1c241(%rip), %rdi     # 0x20fa0
leaq 0xf4ba(%rip), %rsi      # 0x14220
callq 0x4300
movq %rax, %rdi
movq %r14, %rsi
callq 0x42f0
movq %rax, %rdi
callq 0x4170
movq 0x1c21b(%rip), %rdi     # 0x20fa0
leaq 0xf4a7(%rip), %rsi      # 0x14233
callq 0x4300
movq %rax, %rbx
callq 0x43c0
movl %eax, %esi
movq %rbx, %rdi
callq 0x4230
movq %rax, %rdi
callq 0x4170
leaq 0x118(%rsp), %rsi
xorl %edi, %edi
callq 0x41d0
movq 0x1c1df(%rip), %r14     # 0x20fa0
leaq 0xf488(%rip), %rsi      # 0x14250
movq %r14, %rdi
callq 0x4300
movq 0x138(%rsp), %rsi
movq %rax, %rdi
callq 0x42f0
movq %rax, %rdi
callq 0x4170
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 0xf459(%rip), %rsi      # 0x14270
movq %r14, %rdi
callq 0x4300
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
andl 0x18(%rax,%rdx), %ebx
orl $0x80, %ebx
movl %ebx, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x8, 0x10(%rax,%rcx)
leaq 0xf42d(%rip), %rsi      # 0x14275
movq %rax, %rdi
callq 0x4300
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movl $0xffffff4f, %ebx       # imm = 0xFFFFFF4F
movl 0x18(%rax,%rdx), %esi
andl %ebx, %esi
orl $0x80, %esi
movl %esi, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x10, 0x10(%rax,%rcx)
leaq 0xf3f8(%rip), %rsi      # 0x14278
movq %rax, %rdi
callq 0x4300
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
andl 0x18(%rax,%rdx), %ebx
orl $0x80, %ebx
movl %ebx, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x10, 0x10(%rax,%rcx)
leaq 0xf3ca(%rip), %rsi      # 0x1427b
movq %rax, %rdi
callq 0x4300
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movl $0xffffff4f, %esi       # imm = 0xFFFFFF4F
andl 0x18(%rax,%rdx), %esi
orl $0x80, %esi
movl %esi, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x10, 0x10(%rax,%rcx)
leaq 0xf397(%rip), %rsi      # 0x1427e
movq %rax, %rdi
callq 0x4300
movq %rax, %rdi
callq 0x4170
pushq $0x14
popq %rbx
movl $0xffffff4f, %ebp       # imm = 0xFFFFFF4F
cmpq $0x8c, %rbx
je 0x5040
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), %rax
movq $0xc, 0x10(%r14,%rax)
movq 0x10(%rsp), %rax
movq -0x14(%rax,%rbx), %rsi
movq %r14, %rdi
callq 0x4300
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 $0x8, 0x10(%rdi,%rax)
movslq 0x4c(%rsp,%rbx), %rcx
testq %rcx, %rcx
je 0x4f81
movq 0x3c(%rsp,%rbx), %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
jmp 0x4f83
xorl %esi, %esi
callq 0x4230
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)
movl 0x4c(%rsp,%rbx), %esi
movq %rax, %rdi
callq 0x4480
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 0x50(%rsp,%rbx), %rcx
testq %rcx, %rcx
je 0x4ff8
movq 0x44(%rsp,%rbx), %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
jmp 0x4ffa
xorl %esi, %esi
callq 0x4230
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)
movl 0x50(%rsp,%rbx), %esi
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
callq 0x4170
addq $0x18, %rbx
jmp 0x4eff
pushq $0x20
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0xd0, %rdi
callq 0x4140
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x5043
leaq 0x38(%rsp), %rdi
callq 0x5750
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x4140
jmp 0x50cb
jmp 0x5091
jmp 0x5096
jmp 0x5096
movq %rax, %rbx
jmp 0x50cb
movq %rax, %rbx
pushq $0x20
popq %r14
leaq (%rsp,%r14), %rdi
addq $0xd0, %rdi
callq 0x4140
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x509d
jmp 0x50cb
jmp 0x50bb
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x56ca
leaq 0x38(%rsp), %rdi
callq 0x5750
movq %rbx, %rdi
callq 0x44c0