Reputation: 147
I just started learning scala. Is there any way to find CPU time and real time and the cores used by the program when using actor model??
Thanks in advance.
Upvotes: 1
Views: 343
Reputation: 1312
If you are running in Linux (specifically here I'm describing Ubuntu) mpstat
is a useful program.
You can install it using the following command:
sudo apt-get install sysstat
Once installed you can run a bash script to record CPU info. In this case I'm logging 10 times a second. This will block until you press Control-C to kill the logging. (Also, consider removing the sleep 0.1;
for better data.)
while x=0; do mpstat -P ALL >> cpu_log.txt; sleep 0.1; done
In another terminal you can fire off your program (or ANY program) and see track the performance data. The output looks like this:
03:21:08 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
03:21:08 PM all 0.37 0.00 0.33 0.50 0.00 0.02 0.00 0.00 98.78
03:21:08 PM 0 0.51 0.00 0.45 0.57 0.00 0.03 0.00 0.00 98.43
03:21:08 PM 1 0.29 0.00 0.26 0.45 0.00 0.01 0.00 0.00 99.00
Upvotes: 0
Reputation: 2620
how about using the unix system time function ?
time scalac HelloWorld.scala
Upvotes: 0
Reputation: 62835
You may use a profiler such as VisualVM or more adhoc and pleasant solution: Typesafe console.
Upvotes: 1