Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

swh:1:snp:3412a66e65bea20b7e168a888d9d72c2f394bcad
  • Code
  • Branches (1)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    No releases to show
  • d272118
  • /
  • scripts
  • /
  • analyseQueryTimes.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
content badge Iframe embedding
swh:1:cnt:e38799f38a0d1800ab9894e4417112273ab8dafc
directory badge Iframe embedding
swh:1:dir:e6c9e61944818b7d08c0fabf236343e9775c5126
revision badge
swh:1:rev:ab7816a53dfc5d650f47a973bebdea440b254151
snapshot badge
swh:1:snp:3412a66e65bea20b7e168a888d9d72c2f394bcad

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: ab7816a53dfc5d650f47a973bebdea440b254151 authored by bartvbl on 25 October 2020, 14:50:57 UTC
Updated publishing information
Tip revision: ab7816a
analyseQueryTimes.py
import os
import os.path
import json

def loadOutputFileDirectory(path):
    originalFiles = os.listdir(path)
    results = []
    for fileindex, file in enumerate(originalFiles):
        print(str(fileindex+1) + '/' + str(len(originalFiles)), file)
        if(file == 'raw'):
        	continue
        with open(os.path.join(path, file), 'r') as openFile:
            fileContents = json.loads(openFile.read())
            results.append(fileContents)
    return results

results = loadOutputFileDirectory('../input/hamming_tree_query_times_by_authors/')

counts = [0] * 4096
sums = [0] * 4096

with open('../output/figure_7_query_times.csv', 'w') as outFile:
    outFile.write('Index, End time\n') # , Counts
    for i in range(0, len(results)):
        for row in range(0, 4096):
            value = results[i]['indexedQueryResults']['distanceTimes'][row]
            if value != -1:
                counts[row] += 1
                sums[row] += value
    for i in range(0, 4096):
        if counts[i] == 0:
            continue
        outFile.write(str(i) + ', ' + str(float(sums[i]) / float(counts[i])) + '\n') #  + ', ' + str(counts[i])

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API