-1

I am currently using time command from the terminal to check how much time my java program took, using the following command.

time java  -Djava.util.concurrent.ForkJoinPool.common.parallelism=40 TestingNumberOfThreads

// Result
real    0m4.356s
user    0m46.273s
sys 0m0.702s

Is there a way I can achieve the same from IntelliJ?

Neeraj Jain
  • 7,643
  • 6
  • 34
  • 62
  • 1
    I mean, why cant you use , System.currentTimeMillis() at the beginning and at the end of the program . Simply subtract these values to get execution time – NiksVij Jun 28 '19 at 19:28
  • 1
    Honestly, you do not **time** java applications. If you perceive a performance problem, you **benchmark** them. https://stackoverflow.com/questions/504103/how-do-i-write-a-correct-micro-benchmark-in-java ... – GhostCat Jun 28 '19 at 19:30
  • @NiksVij I can definitely do that and I use `System.nanoTime()` instead of `System.currentTimeMillis()` to get more accurate results whenever required, I just want to know if there is a way to specify time command in IntelliJ. Nothing less nothing more. – Neeraj Jain Jun 28 '19 at 20:00
  • @GhostCat I just want to know if there is a way to add the "time" command from IntelliJ configurations. I don't want to debug any performance problem as of now. – Neeraj Jain Jun 28 '19 at 20:01
  • 1
    Does this answer your question? [Checking Run time in IntelliJ IDEA](https://stackoverflow.com/questions/1210081/checking-run-time-in-intellij-idea) – avp Jul 31 '22 at 18:24

2 Answers2

0

You’d need a profiler. I believe the plugin VisualVM Profiler for IntelliJ might be what you’re looking for. Here’s the link to it: https://plugins.jetbrains.com/plugin/3749-visualvm-profiler/

vtboyarc
  • 23
  • 1
  • 7
0

To open the terminal window in Intellij,

From the main menu, select View | Tool Windows | Terminal or press Alt+F12.

See https://www.jetbrains.com/help/idea/terminal-emulator.html#open-terminal

Once you opened the terminal window in the IDE, you can run any command you like, including, but not limited to

time java  -Djava.util.concurrent.ForkJoinPool.common.parallelism=40 TestingNumberOfThreads

You can even separate this terminal command into its own file, named to something like mycommand.sh. And, assuming that this file contains the command above, you can simplify your command to

sh <yourpath>/mycommand.sh
Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175