// File: /workspace/github_cpp_makefile_star2_O3/Barath-Kannan[P]SignalsAndSlots/test/SignalTest_Parametrized.cpp
// Function: SignalTestParametrized_IntenseUsage_Test::TestBody()
TEST_P(SignalTestParametrized, IntenseUsage) {
    auto func = ([this](sigType x) {
        volatile sigType v = x;
        for (uint32_t i = 0; i < params.nOperations; i++) {
            v+=x;
        }
        completedFunctions++;
    });

    Signal<sigType> signal(params.threadSafe);
    cout << "Connecting " << params.nConnections << " functions" << endl;
    for (uint32_t i = 0; i < params.nConnections; i++) {
        signal.connectSlot(params.scheme, func);
    }

    FunctionTimeRegular<> printer([this]() {
        cout << "Total elements emitted: " << counter << " / " << params.nEmissions << fixed << endl;
        cout << "Emission rate: " << (double) counter / bt.getElapsedMilliseconds() << fixed << "m/ms" << endl;
        cout << "Total elements processed: " << completedFunctions << " / " << params.nEmissions * params.nConnections << fixed << endl;
        cout << "Operation rate: " << (double) completedFunctions * params.nOperations / bt2.getElapsedNanoseconds() << "m/ns" << endl;
        return (bt2.getElapsedSeconds() < 6000);
    }, std::chrono::milliseconds(500));

    FunctionTimeRegular<> checkFinished([this]() {
        return (completedFunctions != params.nEmissions * params.nConnections);
    }, std::chrono::milliseconds(1));

    cout << "Starting emission thread: " << endl;
    
    std::list<thread> emitters;
    for (uint32_t i=0; i<params.nEmitters; ++i){
        emitters.emplace_back([this, &signal, i]() {
            if (i==0){
                bt2.start();
                bt.start();
            }
            uint32_t current;
            while ((current = counter.fetch_add(1000)) < params.nEmissions-1000){
                for (uint32_t j=0; j<1000; ++j) signal.emitSignal(1);
            }
            if (current == params.nEmissions-1000){
                for (uint32_t j=0; j<1000; ++j) signal.emitSignal(1);
                bt.stop();
            }
        });
    }
    cout << "Emission thread spawned" << endl;
    cout.precision(std::numeric_limits<double>::max_digits10);
    for (auto &t : emitters){
        t.join();
    }
    cout << "Emission completed" << endl;
    checkFinished.join();
    bt2.stop();
    printer.stopAndJoin();
    cout << "Processing completed" << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdi, %rbx
movb 0x28(%rdi), %al
xorl %r15d, %r15d
leaq 0x1b0(%rsp), %r14
movl %r15d, -0x40(%r14)
movb %al, -0x3c(%r14)
xorps %xmm0, %xmm0
movups %xmm0, -0x38(%r14)
movups %xmm0, -0x28(%r14)
movups %xmm0, -0x18(%r14)
movq %r15, -0x8(%r14)
movq %r14, %rdi
callq 0xb7c0
movb %r15b, 0x40(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r14)
leaq 0x200(%rsp), %rax
movl %r15d, (%rax)
movq %r15, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
leaq 0x260(%rsp), %rax
movl %r15d, (%rax)
movq %r15, 0x8(%rax)
movups %xmm0, -0x40(%rax)
movups %xmm0, -0x30(%rax)
movups %xmm0, -0x20(%rax)
movb %r15b, -0x10(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %r15, 0x20(%rax)
movq 0x4d633(%rip), %rdi     # 0x6afa0
leaq 0x2d47f(%rip), %rsi     # 0x4adf3
movl $0xb, %edx
callq 0xb600
movl 0x18(%rbx), %esi
movq 0x4d618(%rip), %rdi     # 0x6afa0
callq 0xb380
movq %rax, %r14
leaq 0x2d468(%rip), %rsi     # 0x4adff
movl $0xa, %edx
movq %rax, %rdi
callq 0xb600
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0xb4c0
movsbl %al, %esi
movq %r14, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb390
cmpl $0x0, 0x18(%rbx)
je 0x1da32
xorl %ebp, %ebp
leaq 0x129a(%rip), %r12      # 0x1ec74
leaq 0x12b3(%rip), %r13      # 0x1ec94
leaq 0x170(%rsp), %r14
leaq 0x30(%rsp), %r15
movl 0x2c(%rbx), %esi
movq $0x0, 0x38(%rsp)
movq %rbx, 0x30(%rsp)
movq %r12, 0x48(%rsp)
movq %r13, 0x40(%rsp)
movq %r14, %rdi
movq %r15, %rdx
callq 0x1f9b4
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x1da2b
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
incl %ebp
cmpl 0x18(%rbx), %ebp
jb 0x1d9ee
leaq 0x50(%rsp), %rsi
movq $0x0, 0x8(%rsi)
movq %rbx, (%rsi)
leaq 0x1271(%rip), %rax      # 0x1ecba
movq %rax, 0x18(%rsi)
leaq 0x14cc(%rip), %rax      # 0x1ef20
movq %rax, 0x10(%rsi)
leaq 0x10(%rsp), %rdx
movq $0x1f4, (%rdx)          # imm = 0x1F4
leaq 0xe0(%rsp), %rdi
callq 0x1fa2e
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x1da8a
leaq 0x50(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x10(%rsp), %rsi
movq $0x0, 0x8(%rsi)
movq %rbx, (%rsi)
leaq 0x14a5(%rip), %rax      # 0x1ef46
movq %rax, 0x18(%rsi)
leaq 0x14ae(%rip), %rax      # 0x1ef5a
movq %rax, 0x10(%rsi)
leaq 0x8(%rsp), %rdx
movq $0x1, (%rdx)
leaq 0x50(%rsp), %rdi
callq 0x1fa2e
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x1dadf
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x4d4ba(%rip), %r15     # 0x6afa0
leaq 0x2d31d(%rip), %rsi     # 0x4ae0a
movl $0x1a, %edx
movq %r15, %rdi
callq 0xb600
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xb4c0
movsbl %al, %esi
movq 0x4d488(%rip), %rdi     # 0x6afa0
callq 0xb050
movq %rax, %rdi
callq 0xb390
leaq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x0, 0x24(%rbx)
je 0x1dbcc
xorl %ebp, %ebp
leaq 0x170(%rsp), %r14
leaq 0x8(%rsp), %r12
leaq 0x10(%rsp), %r13
movl $0x18, %edi
callq 0xb4e0
movq %rax, %r15
movq $0x0, 0x10(%rax)
movl $0x20, %edi
callq 0xb4e0
movq %r15, %rdi
addq $0x10, %rdi
leaq 0x4bed8(%rip), %rcx     # 0x69a60
movq %rcx, (%rax)
movq %rbx, 0x8(%rax)
movq %r14, 0x10(%rax)
movl %ebp, 0x18(%rax)
movq %rax, 0x8(%rsp)
movq %r12, %rsi
xorl %edx, %edx
callq 0xb4a0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1dbb5
movq (%rdi), %rax
callq *0x8(%rax)
movq %r15, %rdi
movq %r13, %rsi
callq 0xb0a0
incq 0x20(%rsp)
incl %ebp
cmpl 0x24(%rbx), %ebp
jb 0x1db5b
movq 0x4d3cd(%rip), %r15     # 0x6afa0
leaq 0x2d24b(%rip), %rsi     # 0x4ae25
movl $0x17, %edx
movq %r15, %rdi
callq 0xb600
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xb4c0
movsbl %al, %esi
movq 0x4d39b(%rip), %r15     # 0x6afa0
movq %r15, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb390
movq (%r15), %rax
movq -0x18(%rax), %rax
movq $0x11, 0x8(%r15,%rax)
leaq 0x10(%rsp), %r14
movq (%r14), %r14
leaq 0x10(%rsp), %rax
cmpq %rax, %r14
je 0x1dc42
leaq 0x10(%r14), %rdi
callq 0xb9a0
jmp 0x1dc2a
movq 0x4d357(%rip), %r14     # 0x6afa0
leaq 0x2d1ed(%rip), %rsi     # 0x4ae3d
movl $0x12, %edx
movq %r14, %rdi
callq 0xb600
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0xb4c0
movsbl %al, %esi
movq 0x4d325(%rip), %rdi     # 0x6afa0
callq 0xb050
movq %rax, %rdi
callq 0xb390
leaq 0xb0(%rsp), %rdi
callq 0xb9a0
addq $0x48, %rbx
movq %rbx, %rdi
callq 0xd664
xorl %eax, %eax
leaq 0x110(%rsp), %rdi
xchgb %al, -0x30(%rdi)
callq 0xb280
leaq 0x140(%rsp), %rdi
callq 0xb9a0
movq 0x4d2d9(%rip), %rbx     # 0x6afa0
leaq 0x2d182(%rip), %rsi     # 0x4ae50
movl $0x14, %edx
movq %rbx, %rdi
callq 0xb600
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0xb4c0
movsbl %al, %esi
movq 0x4d2a7(%rip), %rdi     # 0x6afa0
callq 0xb050
movq %rax, %rdi
callq 0xb390
leaq 0x10(%rsp), %rdi
callq 0x1510e
leaq 0x50(%rsp), %rdi
callq 0x1fb28
leaq 0xe0(%rsp), %rdi
callq 0x1fb28
leaq 0x170(%rsp), %rdi
callq 0x223c6
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1ddf3
jmp 0x1ddf3
movq %rax, %rbx
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x1de12
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1de12
jmp 0x1ddf3
movq %rax, %rbx
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x1de1f
leaq 0x50(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1de1f
jmp 0x1ddf3
movq %rax, %rbx
jmp 0x1de08
movq %rax, %rbx
jmp 0x1de1f
jmp 0x1ddf3
jmp 0x1ddfb
jmp 0x1ddfb
movq %rax, %rbx
jmp 0x1ddc6
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1ddc6
movq (%rdi), %rax
callq *0x8(%rax)
movl $0x18, %esi
movq %r15, %rdi
callq 0xb510
jmp 0x1ddfe
movq %rax, %rbx
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x1de1f
leaq 0x30(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1de1f
movq %rax, %rdi
callq 0xd7cf
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1510e
leaq 0x50(%rsp), %rdi
callq 0x1fb28
leaq 0xe0(%rsp), %rdi
callq 0x1fb28
leaq 0x170(%rsp), %rdi
callq 0x223c6
movq %rbx, %rdi
callq 0xba10