User Tools

Site Tools


Sidebar

Systems Engineering Wiki

Experimenting

experimenting:throughput_flowtime

Computing throughput and flow time

An example script to compute the throughput of a system and the flow time of an item is listed here

#!/usr/bin/env python
#
'''
 
Input:
    Lines containing values:
        current-time \t product-number \t entry-time
 
    (product-number starts with 0)
 
Output:
    Lines containing values:
        line-number \t throughput \t avg-flow-time
 
'''
 
import sys
 
 
line_count = 0
avg_flow_time = 0.0
 
for line in sys.stdin.xreadlines():
    line_count = line_count + 1
 
    values = line.split("\t")
    assert len(values) == 3 # We should have 3 values on a line
 
    cur_time = float(values[0])
    prod_number = int(values[1])
    entry_time = float(values[2])
    #print "line= %f %d %f" % (cur_time, prod_number, entry_time)
 
    throughput = float(line_count) / cur_time
 
    avg_flow_time = (line_count - 1) / float(line_count) * avg_flow_time \
                    + (cur_time - entry_time) / float(line_count)
 
    print "%d\t%f\t%f" % (line_count, throughput, avg_flow_time)

Save this script as calc_tp_aft.py.

You can use this script with a Chi simulation with a line like

$ startmodel mymodel | python calc_tp_aft.py

or (if you previously captured the output in a file my_output):

$ cat my_output | python calc_tp_aft.py

The results of the computation are put on the screen. If you want to capture it in a file, append “> results.txt” as in

$ startmodel mymodel | python calc_tp_aft.py > results.txt
experimenting/throughput_flowtime.txt · Last modified: Wednesday, 29 August 2007 : 16:40:23 (external edit)