User Tools

Site Tools


experimenting:throughput_flowtime

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

experimenting:throughput_flowtime [Wednesday, 29 August 2007 : 16:40:23] (current)
Line 1: Line 1:
 +====== 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
 +<code python>
 +#​!/​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)
 +</​code>​
 +Save this script as ''​calc_tp_aft.py''​.
 +
 +You can use this script with a Chi simulation with a line like
 +<​code>​
 +$ startmodel mymodel | python calc_tp_aft.py
 +</​code>​
 +or (if you previously captured the output in a file ''​my_output''​):​
 +<​code>​
 +$ cat my_output | python calc_tp_aft.py
 +</​code>​
 +
 +The results of the computation are put on the screen. If you want to capture it in a file, append ''">​ results.txt"''​ as in
 +<​code>​
 +$ startmodel mymodel | python calc_tp_aft.py > results.txt
 +</​code>​
experimenting/throughput_flowtime.txt · Last modified: Wednesday, 29 August 2007 : 16:40:23 (external edit)