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

  • 5047386
  • /
  • flattening_thresh.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
content badge
swh:1:cnt:136f3f25af87d45becdc19fb402c30c91a014808
directory badge
swh:1:dir:50473866082fc18b42173bdb06907d59a8383528

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
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
flattening_thresh.py
#!/usr/bin/env python

import math
import argparse

def genFlattenModules(benchName):

    fn = benchName+'.out'
    f = open(fn,'r')
    r = f.read().split('\n')
    f.close()

    l = filter(lambda x: (len(x)>1), r)
    #print l

    m = map(lambda x: x.replace(':',''), l)
    m = map(lambda x: x.split(), m)
    #print m
    
    vals = map(lambda x: int(x[1]), m)
    #print vals 

    numVals = len(vals)
    print '\t[flattening_thresh.py] Total Num of Functions = ',numVals

    names = ['000k','001k','010k','125k','300k','1M','2M','25M']
    buckets = [(0,0),(0,1000),(1000,10000),(10000,125000),(125000,300000),(300000,1000000),(1000000,2000000),(2000000,25000000)]

    numBuckets = len(buckets)
    
    histVals = []

    for i in range(numBuckets):
        n = filter(lambda x: (int(x[1])>=buckets[i][0]) and (int(x[1])<buckets[i][1]), m)
        histVals.append(len(n))

    sumFunc = 0
    for i in range(numBuckets):
        print '\t',buckets[i][0],'-',buckets[i][1],' : ',histVals[i]
        sumFunc = sumFunc+histVals[i]

    print '\t>',buckets[-1][1] ,': ', numVals - sumFunc

    for i in range(numBuckets):
        can1k = filter(lambda x: (int(x[1])>=0) and (int(x[1])<buckets[i][1]), m)
        n1k = map(lambda x: x[0], can1k)
        fn = benchName+'.flat'+names[i]+'.txt'
    
        fout = open(fn,'w')
    
        for e in n1k:
            fout.write(e)
            fout.write('\n')

        fout.close()

    

parser = argparse.ArgumentParser(description='Generate flattened module list for this benchmark')

parser.add_argument("input")

args = parser.parse_args()

genFlattenModules(args.input)

back to top

Software Heritage — Copyright (C) 2015–2026, 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