<jupyter_start><jupyter_text>Real case - Analyst times (5 Peers)  Imports<jupyter_code>import threading
import requests
import json
import random
import plotly
import plotly.graph_objs as go
from analyst import *<jupyter_output><empty_output><jupyter_text>Global variables<jupyter_code>API_ENDPOINT = "http://172.16.58.3:3000/api/"
NS = "ertis.uma.nuclear"<jupyter_output><empty_output><jupyter_text>Function<jupyter_code>def addAnalysisTest(num_analysts, num_acqs):
    analyst_threads = []
    analysis_per_worker = int(num_acqs/num_analysts)
    
    # Check for next analysis id
    resource_url = f"{API_ENDPOINT}{NS}.Analysis"
    r = requests.get(resource_url)
    next_id = len(r.json()) + 1
    
    # Create threads
    for i in range(num_analysts):
        thread = Analyst(i, f"Analyst-{i}", analysis_per_worker, next_id+analysis_per_worker*i, API_ENDPOINT, NS)
        analyst_threads.append(thread)
        
    # Start threads
    for i in range(num_analysts):
        analyst_threads[i].start()
        
    # Join threads
    for i in range(num_analysts):
        analyst_threads[i].join()
        
    # Print results
    min_get = analyst_threads[0].min_get
    avg_get = analyst_threads[0].avg_get
    max_get = analyst_threads[0].max_get
    min_add = analyst_threads[0].min_add
    avg_add = analyst_threads[0].avg_add
    max_add = analyst_threads[0].max_add
    analyst_threads[0].printResults()
    for i in range(1, num_analysts):
        if analyst_threads[i].min_get < min_get:
            min_get = analyst_threads[i].min_get

        avg_get = avg_get + analyst_threads[i].avg_get

        if analyst_threads[i].max_get > max_get:
            max_get = analyst_threads[i].max_get
            
        if analyst_threads[i].min_add < min_add:
            min_add = analyst_threads[i].min_add
            
        avg_add = avg_add + analyst_threads[i].avg_add
        
        if analyst_threads[i].max_get > max_get:
            max_add = analyst_threads[i].max_add

        analyst_threads[i].printResults()

    print(f"MIN GET ACQ --> {min_get}")
    print(f"AVG GET ACQ --> {avg_get/num_analysts}")
    print(f"MAX GET ACQ --> {max_get}")
    print(f"MIN ADD ANA --> {min_add}")
    print(f"AVG ADD ANA --> {avg_add/num_analysts}")
    print(f"MAX ADD ANA --> {max_add}")

    print("Add Analysis Test Finalized")<jupyter_output><empty_output><jupyter_text>Execution of the test (100 analysis to do) with one single analyst<jupyter_code>addAnalysisTest(1, 100) #Analysts, Analysis to do<jupyter_output>Analyst Analyst-0 has started
Analyst Analyst-0 has finished
Analyst-0 - Fastest acquisition gotten in 0.12300682067871094 seconds
Analyst-0 - Slowest acquisition gotten in 0.39402246475219727 seconds
Analyst-0 - Average time getting acquisitions: 0.1397079920768738 seconds
Analyst-0 - Fastest analysis added in 2.2181267738342285 seconds
Analyst-0 - Slowest analysis added in 2.3491342067718506 seconds
Analyst-0 - Average time adding analysis: 2.252398822307587 seconds
MIN GET ACQ --> 0.12300682067871094
AVG GET ACQ --> 0.1397079920768738
MAX GET ACQ --> 0.39402246475219727
MIN ADD ANA --> 2.2181267738342285
AVG ADD ANA --> 2.252398822307587
MAX ADD ANA --> 2.3491342067718506
Add Analysis Test Finalized<jupyter_text>Execution of the test (100 analysis to do) with two (2) analysts<jupyter_code>addAnalysisTest(2, 100) #Analysts, Analysis to do<jupyter_output>Analyst Analyst-0 has startedAnalyst Analyst-1 has started

Analyst Analyst-1 has finished
Analyst Analyst-0 has finished
Analyst-0 - Fastest acquisition gotten in 0.12300705909729004 seconds
Analyst-0 - Slowest acquisition gotten in 0.20801162719726562 seconds
Analyst-0 - Average time getting acquisitions: 0.14372823715209962 seconds
Analyst-0 - Fastest analysis added in 0.49202823638916016 seconds
Analyst-0 - Slowest analysis added in 2.633150815963745 seconds
Analyst-0 - Average time adding analysis: 2.164023771286011 seconds
Analyst-1 - Fastest acquisition gotten in 0.12300705909729004 seconds
Analyst-1 - Slowest acquisition gotten in 0.2170124053955078 seconds
Analyst-1 - Average time getting acquisitions: 0.14158812999725343 seconds
Analyst-1 - Fastest analysis added in 0.3110177516937256 seconds
Analyst-1 - Slowest analysis added in 2.419138193130493 seconds
Analyst-1 - Average time adding analysis: 2.1512830305099486 seconds
MIN GET ACQ --> 0.12300705909729004
AVG GET ACQ --> 0[...]<jupyter_text>Execution of the test (100 analysis to do) with five (5) analysts<jupyter_code>addAnalysisTest(5, 100) #Analysts, Analysis to do<jupyter_output>Analyst Analyst-0 has startedAnalyst Analyst-1 has started

Analyst Analyst-2 has started
Analyst Analyst-3 has started
Analyst Analyst-4 has started
Analyst Analyst-2 has finished
Analyst Analyst-3 has finished
Analyst Analyst-4 has finished
Analyst Analyst-1 has finished
Analyst Analyst-0 has finished
Analyst-0 - Fastest acquisition gotten in 0.12300705909729004 seconds
Analyst-0 - Slowest acquisition gotten in 0.38602209091186523 seconds
Analyst-0 - Average time getting acquisitions: 0.15575895309448243 seconds
Analyst-0 - Fastest analysis added in 0.6170351505279541 seconds
Analyst-0 - Slowest analysis added in 2.306131601333618 seconds
Analyst-0 - Average time adding analysis: 2.068218231201172 seconds
Analyst-1 - Fastest acquisition gotten in 0.1260073184967041 seconds
Analyst-1 - Slowest acquisition gotten in 0.3690211772918701 seconds
Analyst-1 - Average time getting acquisitions: 0.16215933561325074 seconds
Analyst-1 - Fastest analysis added in 2.2191269397735596 seconds
Analy[...]<jupyter_text>Execution of the test (100 analysis to do) with ten (10) analysts<jupyter_code>addAnalysisTest(10, 100) #Analysts, Analysis to do<jupyter_output>Analyst Analyst-0 has started
Analyst Analyst-1 has started
Analyst Analyst-2 has started
Analyst Analyst-3 has started
Analyst Analyst-4 has started
Analyst Analyst-5 has started
Analyst Analyst-6 has started
Analyst Analyst-7 has startedAnalyst Analyst-8 has started

Analyst Analyst-9 has started
Analyst Analyst-5 has finished
Analyst Analyst-9 has finished
Analyst Analyst-2 has finished
Analyst Analyst-0 has finished
Analyst Analyst-1 has finished
Analyst Analyst-4 has finished
Analyst Analyst-8 has finished
Analyst Analyst-6 has finishedAnalyst Analyst-3 has finished

Analyst Analyst-7 has finished
Analyst-0 - Fastest acquisition gotten in 0.13000726699829102 seconds
Analyst-0 - Slowest acquisition gotten in 0.39402246475219727 seconds
Analyst-0 - Average time getting acquisitions: 0.20311157703399657 seconds
Analyst-0 - Fastest analysis added in 0.5090291500091553 seconds
Analyst-0 - Slowest analysis added in 2.3611347675323486 seconds
Analyst-0 - Average time adding analysis: 1.8[...]<jupyter_text>Execution of the test (100 analysis to do) with twenty five (25) analysts<jupyter_code>addAnalysisTest(25, 100) #Analysts, Analysis to do<jupyter_output>Analyst Analyst-0 has started
Analyst Analyst-1 has started
Analyst Analyst-2 has started
Analyst Analyst-3 has startedAnalyst Analyst-4 has started
Analyst Analyst-5 has started
Analyst Analyst-6 has started

Analyst Analyst-7 has started
Analyst Analyst-8 has startedAnalyst Analyst-9 has started
Analyst Analyst-10 has started

Analyst Analyst-11 has started
Analyst Analyst-12 has started
Analyst Analyst-13 has started
Analyst Analyst-14 has started
Analyst Analyst-15 has started
Analyst Analyst-16 has started
Analyst Analyst-17 has started
Analyst Analyst-18 has started
Analyst Analyst-19 has started
Analyst Analyst-20 has started
Analyst Analyst-21 has started
Analyst Analyst-22 has started
Analyst Analyst-23 has started
Analyst Analyst-24 has started
Analyst Analyst-17 has finished
Analyst Analyst-19 has finishedAnalyst Analyst-24 has finished

Analyst Analyst-13 has finishedAnalyst Analyst-1 has finished

Analyst Analyst-20 has finished
Analyst Analyst-0 has finishedAnalyst Analys[...]<jupyter_text>Execution of the test (100 analysis to do) with fifty (50) analysts<jupyter_code>addAnalysisTest(50, 100) #Analysts, Analysis to do<jupyter_output>Analyst Analyst-0 has startedAnalyst Analyst-1 has started
Analyst Analyst-2 has started
Analyst Analyst-3 has started

Analyst Analyst-4 has startedAnalyst Analyst-5 has started

Analyst Analyst-6 has startedAnalyst Analyst-7 has started

Analyst Analyst-8 has started
Analyst Analyst-9 has started
Analyst Analyst-10 has started
Analyst Analyst-11 has started
Analyst Analyst-12 has started
Analyst Analyst-13 has started
Analyst Analyst-14 has started
Analyst Analyst-15 has started
Analyst Analyst-16 has started
Analyst Analyst-17 has startedAnalyst Analyst-18 has started

Analyst Analyst-19 has started
Analyst Analyst-20 has started
Analyst Analyst-21 has started
Analyst Analyst-22 has started
Analyst Analyst-23 has started
Analyst Analyst-24 has started
Analyst Analyst-25 has startedAnalyst Analyst-26 has started

Analyst Analyst-27 has startedAnalyst Analyst-28 has started

Analyst Analyst-29 has started
Analyst Analyst-30 has started
Analyst Analyst-31 has started
Analyst Analyst-32[...]<jupyter_text>Activating Plotly (scientific graphing library)<jupyter_code>plotly.offline.init_notebook_mode(connected=True)<jupyter_output><empty_output><jupyter_text>Charts<jupyter_code>num_analysts = ["ONE", "TWO", "FIVE", "TEN", "TWENTY FIVE", "FIFTY"]

min_get_acq = [0.12300682067871094, 0.12300705909729004, 0.12300705909729004, 0.12300705909729004, 0.12700724601745605, 0.1240072250366211]
avg_get_acq = [0.1397079920768738, 0.14265818357467652, 0.16056919813156129, 0.21181210994720456, 0.4906280446052551, 1.2635322546958923]
max_get_acq = [0.39402246475219727, 0.2170124053955078, 0.38602209091186523, 0.6440370082855225, 1.3940796852111816, 2.376136064529419]
min_add_ana = [2.2181267738342285, 0.3110177516937256, 0.6170351505279541, 0.29401683807373047, 0.28801655769348145, 0.27501559257507324]
avg_add_ana = [2.252398822307587, 2.1576534008979795, 2.133221995830536, 1.9954841208457945, 1.8388752055168152, 1.5761401391029357]
max_add_ana = [2.3491342067718506, 2.633150815963745, 2.306131601333618, 2.3611347675323486, 2.303131580352783, 1.1740672588348389]<jupyter_output><empty_output><jupyter_text>Get acquisition times (minimum, average & maximum)<jupyter_code>trace1 = go.Bar(
    x=num_analysts,
    y=min_get_acq,
    name='Minimum'
)
trace2 = go.Bar(
    x=num_analysts,
    y=avg_get_acq,
    name='Average'
)
trace3 = go.Bar(
    x=num_analysts,
    y=max_get_acq,
    name='Maximum'
)
data = [trace1, trace2, trace3]
layout = go.Layout(
    barmode='group',
    title='Times obtained when retrieving acquisition data w/ different number of analysts',
    xaxis=dict(title=dict(text="Number of analysts working at same time")),
    yaxis=dict(title=dict(text="Seconds"))
)

fig = go.Figure(data=data, layout=layout)
plotly.offline.iplot(fig, filename='grouped-bar')<jupyter_output><empty_output><jupyter_text>Add analysis times (minimum, average & maximum)<jupyter_code>trace1 = go.Bar(
    x=num_analysts,
    y=min_add_ana,
    name='Minimum'
)
trace2 = go.Bar(
    x=num_analysts,
    y=avg_add_ana,
    name='Average'
)
trace3 = go.Bar(
    x=num_analysts,
    y=max_add_ana,
    name='Maximum'
)
data = [trace1, trace2, trace3]
layout = go.Layout(
    barmode='group',
    title='Times obtained when executing tx AddAnalysis w/ different number of analysts',
    xaxis=dict(title=dict(text="Analysts working at same time")),
    yaxis=dict(title=dict(text="Seconds"))
)

fig = go.Figure(data=data, layout=layout)
plotly.offline.iplot(fig, filename='grouped-bar')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08147956544231764, 'fraction_numerical': 0.13605794102431454, 'mean_word_length': 4.920877998979071, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '133016', 'license': 'MIT', 'n_tokens_mistral': 4864, 'n_tokens_neox': 3944, 'n_words': 1053, 'path': 'notebooks/old/Analysis_5_Peers.ipynb', 'repo_name': 'JTrillo/NuclearInspections', 'size': '11599'}