def performanceCalculator(count, avg, std, maxv, countref, avgref, stdref, maxvref):
    """ 
    ===========================================================================
    Performance calculator function
    =========================================================================== 
    Calculate performance based on reference values.
    If some value is None return None
    
    **Args**:
        * count : actual number of samples -- (int)
        * avg   :  actual duration average -- (float)
        * std   :  actual duration standar desviation -- (float)
        * maxv  :  actual duration max value -- (float)
        * countref : reference number of samples -- (int)
        * avgref   :  reference duration average -- (float)
        * stdref   :  reference duration standar desviation -- (float)
        * maxvref  :  reference duration max value -- (float)
    **Returns**:
        performance value indicator. [0-1] -- (float)
    """  
    if avgref == None or stdref == None or maxvref == None:
        return None
  
#    f = 0
#    if maxvref == 0: maxvref = 0.1
#    if maxvref < 0.2:
#          f = avg / (maxvref * 10) 
#    if maxvref < 1:
#        f = avg / (maxvref * 5)  
#    if maxvref < 10:
#        f = avg / (maxvref * 2)
#        
#    f = 0
#    if maxvref == 0: maxvref = 0.1
#    if maxvref < 0.2:
#          f = avg / (maxvref * 5) 
#    elif maxvref < 1:
#        f = avg / (maxvref * 3)  
#    elif maxvref < 10:
#        f = avg / (maxvref * 1.5)  
#    else:
#        f = avg / maxvref
#    f = 1-f
     
    if stdref < 0.01: stdref = 0.01
    
    f = (1-((avg - avgref) / (stdref*2)))*0.9
    if f > 1: f=1
    if f < 0: f=0
    
    return f