// File: /workspace/github_cpp_makefile_star2_O2/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 $0xe8, %rsp
movl %edx, %ebp
movq %rsi, (%rsp)
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
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)
cmpl $0x3ff, %edx            # imm = 0x3FF
ja 0x53b9
pushq $0x1
popq %rax
movl %ebp, %ecx
shlq %cl, %rax
movl %ebp, %ecx
shrl $0x6, %ecx
orq %rax, 0x60(%rsp,%rcx,8)
callq 0x42c0
leaq 0x60(%rsp), %rdx
movl $0x80, %esi
movq %rax, %rdi
callq 0x44a0
testl %eax, %eax
je 0x541b
movl %eax, %r15d
movq 0x1bc0a(%rip), %rdi     # 0x20fe8
leaq 0xeecd(%rip), %rsi      # 0x142b2
callq 0x4300
movq %rax, %rdi
movl %ebp, %esi
callq 0x4480
leaq 0xeedf(%rip), %rsi      # 0x142da
movq %rax, %rdi
callq 0x4300
movq %rax, %rdi
movl %r15d, %esi
callq 0x4480
movq %rax, %rdi
callq 0x4170
jmp 0x55cc
leaq 0x20(%rsp), %rdi
movq $0xa, (%rdi)
callq 0x593f
movl 0x78(%r14), %eax
testl %eax, %eax
je 0x544d
cmpl $0x1, %eax
jne 0x55de
leaq 0xd13b(%rip), %rax      # 0x1257f
leaq 0xd125(%rip), %rcx      # 0x12570
jmp 0x545b
movq 0x1bb3c(%rip), %rax     # 0x20f90
movq 0x1bb4d(%rip), %rcx     # 0x20fa8
movq %rcx, %fs:-0x1b8
movq %rax, %fs:-0x1b0
xorl %eax, %eax
leaq 0x18(%rsp), %r15
movq %r14, 0x10(%rsp)
cmpl $0xa, %eax
je 0x559c
movq %rax, 0x8(%rsp)
testb $0x1, 0x84(%r14)
je 0x54a6
movq (%rsp), %rax
movq %rax, %fs:-0x1a8
movq %r14, %rdi
callq 0x5994
pushq $0x1
popq %rbp
cmpq $0x5, %rbp
je 0x5590
movl 0x84(%r14), %eax
btl %ebp, %eax
jae 0x5588
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
imulq $0x18, %rbp, %rax
movq (%rsp), %rcx
addq %rax, %rcx
movq %rcx, %fs:-0x1a8
leaq (%r14,%rax), %rbx
movq -0x10(%r14,%rax), %r12
xorl %r14d, %r14d
cmpq 0x8(%rbx), %r12
jae 0x5569
movq %r12, %rdi
callq 0x473c
movq %rax, %r13
movq %rax, %rdi
movl $0xbd, %esi
movq %r12, %rdx
callq 0x41c0
movl %r14d, %eax
leaq (%rsp,%rax,8), %rdi
addq $0x20, %rdi
andq $0x0, 0x18(%rsp)
movq %r13, %rsi
callq 0x124de
movq %r15, %rdi
callq 0x5b38
incl %r14d
andl $0x7, %r14d
je 0x554b
addq 0x10(%rbx), %r12
jmp 0x54fa
xorl %r13d, %r13d
cmpq $0x40, %r13
je 0x5545
leaq (%rsp,%r13), %rdi
addq $0x20, %rdi
xorl %esi, %esi
callq 0x124de
addq $0x8, %r13
jmp 0x554e
pushq $0x38
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x20, %rdi
callq 0x5b38
addq $-0x8, %rbx
cmpq $-0x8, %rbx
jne 0x556c
movq 0x10(%rsp), %r14
incq %rbp
jmp 0x54a9
movq 0x8(%rsp), %rax
incl %eax
jmp 0x5479
leaq 0x1c11d(%rip), %rax     # 0x216c0
movq %rax, %fs:-0x1a8
leaq 0xcfbd(%rip), %rax      # 0x12570
movq %rax, %fs:-0x1b8
leaq 0xcfbc(%rip), %rax      # 0x1257f
movq %rax, %fs:-0x1b0
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xed00(%rip), %rdi      # 0x142e5
leaq 0xecfb(%rip), %rsi      # 0x142e7
leaq 0xed0a(%rip), %rcx      # 0x142fd
movl $0x109, %edx            # imm = 0x109
callq 0x4220
jmp 0x55ff
movq %rax, %rdi
callq 0x50dd
nop