-1

I'm running a mrjob python script, and in the command line I can pass the number of cores for the system to use.

python example_script.py --num-cores 5 

I'm looking to run the script for n number of cores for beach marking performance test. IE: I want to run it for 1 core, 2 core etc.

Is there anyway I can write a loop directly into the command line rather then having to write out the whole command n number of times?

5
  • 1
    Why would you want to do this? Commented Apr 27, 2018 at 14:22
  • I want to test the performance of the script across n number of cores Commented Apr 27, 2018 at 14:26
  • But why do you want to pass the number of cores that way? Why not a simple integer? That's what a number of cores is, not a range. Commented Apr 27, 2018 at 14:29
  • Possible duplicate of Bash 'for' loop syntax? Commented Apr 27, 2018 at 14:30
  • @mafrasi2 ok, perhaps I wasn't clear. I updated the question there and hope it's clearer now? Commented Apr 27, 2018 at 14:32

2 Answers 2

1

As in you want to lunch 4 isntances of mrjob each with increasing number of cores?

i.e.

python mrjob.py --num-core-instances=1
python mrjob.py --num-core-instances=2
python mrjob.py --num-core-instances=3
python mrjob.py --num-core-instances=4

In that case I don't think you can. You can make a script that lunches those for you though.

import subprocess
for i in range(1,5):
    subprocess.Popen(["start","cmd","/k","python","mrjob.py","--num-core-instance="+i],shell=True)
Sign up to request clarification or add additional context in comments.

Comments

1

Is this what you want to do ?

for i in {1..10} ; do python example_script.py --num-cores $i ; done ;

It is a bash for loop.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.