// File: /workspace/github_cpp_makefile_star2_O3/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 0x5a3a
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 0x5acf
movl %eax, %r15d
movq 0x1a589(%rip), %rdi     # 0x1ffe8
leaq 0x1084c(%rip), %rsi     # 0x162b2
movl $0x27, %edx
callq 0x4370
movq 0x1a571(%rip), %rdi     # 0x1ffe8
movl %ebp, %esi
callq 0x44a0
movq %rax, %rbx
leaq 0x10852(%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 0x5ca7
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 0x5afd
callq 0x4050
cmpl $0x4, (%rax)
je 0x5ae3
movl 0x78(%r14), %eax
testl %eax, %eax
je 0x5b1e
cmpl $0x1, %eax
jne 0x5cb9
leaq 0xe7f2(%rip), %rax      # 0x14307
leaq 0xe7dc(%rip), %rcx      # 0x142f8
jmp 0x5b2c
movq 0x1a473(%rip), %rax     # 0x1ff98
movq 0x1a484(%rip), %rcx     # 0x1ffb0
movq %rcx, %fs:-0x1b8
movq %rax, %fs:-0x1b0
xorl %eax, %eax
movq %rax, 0x8(%rsp)
testb $0x1, 0x84(%r14)
je 0x5b64
movq (%rsp), %rax
movq %rax, %fs:-0x1a8
movq %r14, %rdi
callq 0x5dfc
movl $0x1, %ebp
movl 0x84(%r14), %eax
btl %ebp, %eax
jae 0x5c5a
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
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 0x5c2e
addq %r14, %r13
xorl %ebx, %ebx
movq %r15, %rdi
callq 0x490e
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 0x5bf3
movl $0x1, %esi
callq 0x4310
incl %ebx
andl $0x7, %ebx
jne 0x5c24
xorl %r12d, %r12d
movq 0x10(%rsp,%r12), %rdi
movq $0x0, 0x10(%rsp,%r12)
testq %rdi, %rdi
je 0x5c1a
movl $0x1, %esi
callq 0x4310
addq $0x8, %r12
cmpq $0x40, %r12
jne 0x5bfd
addq 0x10(%r13), %r15
cmpq 0x8(%r13), %r15
jb 0x5bbd
movl $0x38, %ebx
movq 0x10(%rsp,%rbx), %rdi
testq %rdi, %rdi
je 0x5c47
movl $0x1, %esi
callq 0x4310
movq $0x0, 0x10(%rsp,%rbx)
addq $-0x8, %rbx
cmpq $-0x8, %rbx
jne 0x5c33
incq %rbp
cmpq $0x5, %rbp
jne 0x5b69
movq 0x8(%rsp), %rax
incl %eax
cmpl $0xa, %eax
jne 0x5b40
leaq 0x1aa52(%rip), %rax     # 0x206d0
movq %rax, %fs:-0x1a8
leaq 0xe66a(%rip), %rax      # 0x142f8
movq %rax, %fs:-0x1b8
leaq 0xe669(%rip), %rax      # 0x14307
movq %rax, %fs:-0x1b0
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10625(%rip), %rdi     # 0x162e5
leaq 0x10620(%rip), %rsi     # 0x162e7
leaq 0x1062f(%rip), %rcx     # 0x162fd
movl $0x109, %edx            # imm = 0x109
callq 0x4210
jmp 0x5cdc
jmp 0x5cdc
movq %rax, %rdi
callq 0x5803