def view_dupl_sources_time(token, dstore):
    """
    Display the time spent computing duplicated sources
    """
    info = dstore['source_info']
    items = sorted(group_array(info.value, 'source_id').items())
    tbl = []
    tot_time = 0
    for source_id, records in items:
        if len(records) > 1:  # dupl
            calc_time = records['calc_time'].sum()
            tot_time += calc_time + records['split_time'].sum()
            tbl.append((source_id, calc_time, len(records)))
    if tbl and info.attrs.get('has_dupl_sources'):
        tot = info['calc_time'].sum() + info['split_time'].sum()
        percent = tot_time / tot * 100
        m = '\nTotal time in duplicated sources: %d/%d (%d%%)' % (
            tot_time, tot, percent)
        return rst_table(tbl, ['source_id', 'calc_time', 'num_dupl']) + m
    else:
        return 'There are no duplicated sources'
def view_dupl_sources_time ( token , dstore ) : info = dstore [ 'source_info' ] items = sorted ( group_array ( info . value , 'source_id' ) . items ( ) ) tbl = [ ] tot_time = 0 for source_id , records in items : if len ( records ) > 1 : calc_time = records [ 'calc_time' ] . sum ( ) tot_time += calc_time + records [ 'split_time' ] . sum ( ) tbl . append ( ( source_id , calc_time , len ( records ) ) ) if tbl and info . attrs . get ( 'has_dupl_sources' ) : tot = info [ 'calc_time' ] . sum ( ) + info [ 'split_time' ] . sum ( ) percent = tot_time / tot * 100 m = '\nTotal time in duplicated sources: %d/%d (%d%%)' % ( tot_time , tot , percent ) return rst_table ( tbl , [ 'source_id' , 'calc_time' , 'num_dupl' ] ) + m else : return 'There are no duplicated sources'
Display the time spent computing duplicated sources