I have 2 python scripts https://gist.github.com/2233477.
rsgen.pygenerates “random” inputs for use insimulate.pysimulate.pydoes the actual simulation
Thing is, when I start to increase the input size from rsgen.py with the --numReferences param, I get different outputs
# ./rsgen.py --numReferences 1000 > rs.txt; cat rs.txt | xargs ./simulate.py
Number of page faults : 59
# ./rsgen.py --numReferences 100000 > rs.txt; cat rs.txt | xargs ./simulate.py
Number of page faults : 873
Number of page faults : 848
Number of page faults : 823
Number of page faults : 103
./rsgen.py --numReferences 1000000 > rs.txt; cat rs.txt | xargs ./simulate.py
Number of page faults : 866
Number of page faults : 869
Number of page faults : 876
Number of page faults : 907
Number of page faults : 910
Number of page faults : 1001
Number of page faults : 845
...
Notice as I increase numReferences, the python script simulate appears to run more times. Why is that? I am expecting just 1 line of “Number of page faults: …”
This probably has something to do with
xargs‘ARG_MAXwhich defines a batch size for how many args to send to an executable; hence why multiple invocations of your script since it is splitting up the args across multiple calls.Try the
-n(or--max-args) flag ofxargs.A better way alltogether would be to have
simulate.pyaccept a file argument so you could do something like this:It would probably be a lot faster since it avoids the
xargsoverhead