// File: /workspace/github_cpp_makefile_star2_O1/walker-xian[P]teisye/heapperf/heapperf.cpp
// Function: application::test(statistic (&) [5], int)
void test(case_statistics_t& cs, int core) noexcept
    {
		// bind current thread to one core, thus, don't have to sync TSC among cores.
		int errcode{};
#if defined(_WIN32)
		if (!SetThreadAffinityMask(GetCurrentThread(), 1ULL << core))
		{
			errcode = GetLastError();
		}
#else
		cpu_set_t cpuset;
		CPU_ZERO(&cpuset);
		CPU_SET(core, &cpuset); 
		errcode = pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
#endif
		if (errcode)
		{
			cerr << "Failed to bind current thread to core #" << core << ", errcode=" << errcode << endl;
			return;
		}
		// ensure current thread will run on desired core.
		this_thread::sleep_for(10ms);

        switch (_allocator_id)
        {
        case _malloc:
            _active_allocator = ::malloc;
            _active_deallocator = ::free;
            break;
        case _teisye:
            _active_allocator = ::tsalloc;
            _active_deallocator = ::tsfree;
            break;
        default:
            assert(0);
            break;
        }

        for (int n = 0; n < 10; ++n)
        {    	
            if (1 & _case_mask)
            {
                _active_statistic = &cs[_wc];
                test_wc();
            }

            for (int i = 1; i < _test_case_count; ++i)
            {
                if (!((1 << i) & _case_mask)) continue;

                unique_ptr<uint8_t> allocations[8];
                int pos{};

                _active_statistic = &cs[i];
                auto &tc = _test_cases[i];
                for (size_t size = _test_cases[i - 1]._max_size; size < tc._max_size; size += tc._step)
                {
                    auto p = new uint8_t[size];
                    memset(p, 0xbd, size);
                    allocations[pos] = unique_ptr<uint8_t>(p);

                    // hold a little while
                    pos = (pos + 1) % (sizeof(allocations)/sizeof(allocations[0]));
                    if (pos == 0)
                    {
                        for (auto &item : allocations) 
                            item.reset();
                    }
                }
            }
        }

        _active_statistic = &_default_statistic;
        _active_allocator = ::tsalloc;
        _active_deallocator = ::tsfree;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %edx, %ebp
movq %rsi, (%rsp)
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
cmpl $0x3ff, %edx            # imm = 0x3FF
ja 0x5a80
movl $0x1, %eax
movl %ebp, %ecx
shlq %cl, %rax
movl %ebp, %ecx
shrl $0x6, %ecx
orq %rax, 0x50(%rsp,%rcx,8)
callq 0x42b0
leaq 0x50(%rsp), %rdx
movl $0x80, %esi
movq %rax, %rdi
callq 0x44c0
testl %eax, %eax
je 0x5b15
movl %eax, %r15d
movq 0x1a543(%rip), %rdi     # 0x1ffe8
leaq 0x10806(%rip), %rsi     # 0x162b2
movl $0x27, %edx
callq 0x4370
movq 0x1a52b(%rip), %rdi     # 0x1ffe8
movl %ebp, %esi
callq 0x44a0
movq %rax, %rbx
leaq 0x1080c(%rip), %rsi     # 0x162da
movl $0xa, %edx
movq %rax, %rdi
callq 0x4370
movq %rbx, %rdi
movl %r15d, %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
jmp 0x5ceb
leaq 0x10(%rsp), %r15
movq $0x0, (%r15)
movq $0x989680, 0x8(%r15)    # imm = 0x989680
movq %r15, %rdi
movq %r15, %rsi
callq 0x40a0
cmpl $-0x1, %eax
jne 0x5b43
callq 0x4050
cmpl $0x4, (%rax)
je 0x5b29
movl 0x78(%r14), %eax
testl %eax, %eax
je 0x5b64
cmpl $0x1, %eax
jne 0x5cfd
leaq 0xe868(%rip), %rax      # 0x143c3
leaq 0xe852(%rip), %rcx      # 0x143b4
jmp 0x5b72
movq 0x1a42d(%rip), %rax     # 0x1ff98
movq 0x1a43e(%rip), %rcx     # 0x1ffb0
movq %rcx, %fs:-0x1b8
movq %rax, %fs:-0x1b0
xorl %eax, %eax
movq %rax, 0x8(%rsp)
testb $0x1, 0x84(%r14)
je 0x5baa
movq (%rsp), %rax
movq %rax, %fs:-0x1a8
movq %r14, %rdi
callq 0x5e52
movl $0x1, %ebp
movl 0x84(%r14), %eax
btl %ebp, %eax
jae 0x5c9e
xorl %eax, %eax
movq $0x0, 0x10(%rsp,%rax)
addq $0x8, %rax
cmpq $0x40, %rax
jne 0x5bc1
leaq (,%rbp,8), %rax
leaq (%rax,%rax,2), %r13
movq (%rsp), %rax
addq %r13, %rax
movq %rax, %fs:-0x1a8
movq -0x10(%r14,%r13), %r15
cmpq 0x8(%r14,%r13), %r15
jae 0x5c72
addq %r14, %r13
xorl %ebx, %ebx
movq %r15, %rdi
callq 0x493e
movq %rax, %r12
movq %rax, %rdi
movl $0xbd, %esi
movq %r15, %rdx
callq 0x41b0
movl %ebx, %eax
movq 0x10(%rsp,%rax,8), %rdi
movq %r12, 0x10(%rsp,%rax,8)
testq %rdi, %rdi
je 0x5c37
movl $0x1, %esi
callq 0x4310
incl %ebx
andl $0x7, %ebx
jne 0x5c68
xorl %r12d, %r12d
movq 0x10(%rsp,%r12), %rdi
movq $0x0, 0x10(%rsp,%r12)
testq %rdi, %rdi
je 0x5c5e
movl $0x1, %esi
callq 0x4310
addq $0x8, %r12
cmpq $0x40, %r12
jne 0x5c41
addq 0x10(%r13), %r15
cmpq 0x8(%r13), %r15
jb 0x5c01
movl $0x38, %ebx
movq 0x10(%rsp,%rbx), %rdi
testq %rdi, %rdi
je 0x5c8b
movl $0x1, %esi
callq 0x4310
movq $0x0, 0x10(%rsp,%rbx)
addq $-0x8, %rbx
cmpq $-0x8, %rbx
jne 0x5c77
incq %rbp
cmpq $0x5, %rbp
jne 0x5baf
movq 0x8(%rsp), %rax
incl %eax
cmpl $0xa, %eax
jne 0x5b86
leaq 0x1aa0e(%rip), %rax     # 0x206d0
movq %rax, %fs:-0x1a8
leaq 0xe6e2(%rip), %rax      # 0x143b4
movq %rax, %fs:-0x1b8
leaq 0xe6e1(%rip), %rax      # 0x143c3
movq %rax, %fs:-0x1b0
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x105e1(%rip), %rdi     # 0x162e5
leaq 0x105dc(%rip), %rsi     # 0x162e7
leaq 0x105eb(%rip), %rcx     # 0x162fd
movl $0x109, %edx            # imm = 0x109
callq 0x4210
jmp 0x5d20
jmp 0x5d20
movq %rax, %rdi
callq 0x5842