<jupyter_start><jupyter_text>Times obtained during auto analysis test (5 Orgs - 1 Peer Node per Org)  Imports<jupyter_code>import json
import time
import hashlib
import os
import requests
import datetime
import firebase_admin
from firebase_admin import credentials
from firebase_admin import storage<jupyter_output><empty_output><jupyter_text>Global variables<jupyter_code>API_ENDPOINT = "http://172.16.17.32:3000/api/"
NS = "ertis.uma.nuclear"<jupyter_output><empty_output><jupyter_text>Main function<jupyter_code>def addMultipleAutomaticAnalysis():
    cred = credentials.Certificate("serviceAccountKey.json")
    firebase_admin.initialize_app(cred)

    time_list = []
    for i in range(1, 101):
        filename = "acq"
        if i < 10:
            filename = filename + "00" + str(i) + ".txt"
        elif i < 100:
            filename = filename + "0" + str(i) + ".txt"
        else:
            filename = filename + str(i) + ".txt"

        #Download file from repository
        downloadFileFromRepository(filename)

        #Get file content
        acqData = getFileContent(filename)

        #Delete local file
        deleteLocalFile(filename)

        #Send transaction
        elapsed_time = addAutomaticAnalysis(i, acqData)
        time_list.append(elapsed_time)
        print(f"Elapsed time adding automatic analysis for acquisition {i}: {elapsed_time}\r\n")
        time.sleep(2)
    
    print(f"Fastest --> {min(time_list)}")
    print(f"Slowest --> {max(time_list)}")
    print(f"Average --> {sum(time_list)/len(time_list)}")<jupyter_output><empty_output><jupyter_text>Auxiliar functions<jupyter_code>def downloadFileFromRepository(filename):
    bucket = storage.bucket("hyperledger-jte.appspot.com")

    blob = bucket.get_blob(filename)
    blob.download_to_filename(filename)

def checkHashSHA256(filename, hashStored):
    hashValue = sha256(filename)
    return hashValue == hashStored

def sha256(fname):
    hash_sha256 = hashlib.sha256()
    with open(fname, "rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            hash_sha256.update(chunk)
    return hash_sha256.hexdigest()

def getFileContent(filename):
    content = []
    with open(filename, 'r') as f:
        lines = f.readlines()
        for i in range(len(lines)):
            content.append(int(lines[i]))
    return content

def deleteLocalFile(filename):
    if(os.path.exists(filename)):
        os.remove(filename)
    else:
        print(f"File {filename} does not exist")

def addAutomaticAnalysis(acqId, acqData, DEBUG=False):
    resource_url = f"{API_ENDPOINT}{NS}.AddAutomaticAnalysis"
    data = {
        "analysisId": acqId+200,
        "analysisDate": generateDateTime(),
        "acqId": acqId,
        "acqData": acqData
    }
    start_time = time.time()
    r = requests.post(resource_url, data=data)
    elapsed_time = time.time() - start_time
    if DEBUG:
        print(f"Elapsed time: {elapsed_time}")
        print(f"Response status code: {r.status_code}")
        print(r.json())
    return elapsed_time

def generateDateTime():
    x = str(datetime.datetime.now()).replace(" ", "T")
    x2 = x[:len(x)-3]+"Z"

    return x2<jupyter_output><empty_output><jupyter_text>Execution of the test<jupyter_code>addMultipleAutomaticAnalysis()<jupyter_output>Elapsed time adding automatic analysis for acquisition 1: 19.949141025543213

Elapsed time adding automatic analysis for acquisition 2: 19.410110235214233

Elapsed time adding automatic analysis for acquisition 3: 19.458112955093384

Elapsed time adding automatic analysis for acquisition 4: 19.471113681793213

Elapsed time adding automatic analysis for acquisition 5: 19.118093490600586

Elapsed time adding automatic analysis for acquisition 6: 19.201098203659058

Elapsed time adding automatic analysis for acquisition 7: 19.495115041732788

Elapsed time adding automatic analysis for acquisition 8: 19.63912343978882

Elapsed time adding automatic analysis for acquisition 9: 19.345106601715088

Elapsed time adding automatic analysis for acquisition 10: 19.44911241531372

Elapsed time adding automatic analysis for acquisition 11: 19.296103715896606

Elapsed time adding automatic analysis for acquisition 12: 19.577119827270508

Elapsed time adding automatic analysis for acquisition 13: 19.4[...]
{'fraction_non_alphanumeric': 0.09850954820680019, 'fraction_numerical': 0.06544014904517932, 'mean_word_length': 3.90296803652968, 'pattern_counts': {'":': 4, '<': 22, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '411226', 'license': 'MIT', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1316, 'n_words': 332, 'path': 'notebooks/AutoTest5Orgs.ipynb', 'repo_name': 'JTrillo/NuclearInspections', 'size': '4296'}