Generic way to test performance/efficiency of some code? [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Can anybody tell me of a way that one can determine the efficiency of a program that i have written, that is not specific to a particular computer. For instance a piece of code running on an i3 may take 1 second, but on an i7 it may take 0.95 seconds. Then if you test the program again if the computer is doing just a little more work the times may increase to 1.0001 and 0.950003 respectively. I want a way to measure efficiency in a way that would be the same on all archs. Is that (mathematically,...,) possible?

I want a way to measure efficiency in a way that would be the same on all archs
You wont get exactly the same number on the same machine, running at the same CPU speed with the same code and the same version of Java.
You can't hope to get a number which will be the same across architectures, with different versions of Java, CPUs, speed, loads, OSes.
In short, your question is not possible on any real machine. Only a theoretical one which is why big-O is for a theoretical machine (and is derived from the code, not measured)

Related

Is creating a lot of instances the reason my program is slowing down? (JAVA GRAPHICS) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm new to working with java graphics and recently i've noticed that the project i'm working on has been slowing down (lagging, dropping frame rate). I think that the reason why is that instead of making an instance of an object and then drawing it repeatedly i've been making new instances each frame and drawing those. I want to make sure that that's the reason before I start reworking all my code.
thank you
That is hard to tell without seeign the code but you should definetly create or update instances only when needed and draw them repeatedly.
I recommend that you profile your code. Use the profiling stats to decide whether your theory is correct or not.
We would still be guessing about the cause of your "lagging", even if we saw the source code. You should be spending time tuning or rewriting your code based purely on someone's guesses.
FWIW, the overheads of object creation are not as large as some people make out. But GC impacts on realtime behavior because even the best (low-pause) Java GCs have phases where they stop all application threads to perform essential tasks.
And this leads us to the fact that you may be able reduce "lag" by simply tuning the JVM's GC settings. (Assuming that you haven't already tried that .....) I would try GC tuning before doing a massive code rewrite.

Memory usage of a program running in two different languages (C#, Java) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I've written a simple program in two different languages, and the result has astonished me!
My application is a simple program (Hello world!).
The C-Sharp program took about 3 MB of RAM, but in Java-FX it was about 78 MB.
Is Java really using that much memory?!
Is there a way to reduce the amount of memory?
Depending on the version of the java virtual machine, the default initial heap size is a reasonable minimum, varies by platform, and can be set at startup. So yes, you can reduce it.
About changing the size and more details: https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gc-ergonomics.html
About the default heap size: How is the default java heap size determined?

java program that make hard for os to format the removable disk [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Is there any way to create a java program that can executes itself while in a removable disk and cannot let any windows utilities or some third party software format that drive.
Short answer: no.
Long answer: the idea doesn't make sense in the first place. You see, any Java program would sit atop of any operating system. So, if your operating system decides to do something; how could something that runs atop of your OS (and that doesn't control your OS) prevent your OS from doing that?
If somebody has physical control over that drive; then there is nothing that you can do to prevent that person from erasing, formatting, ... that drive.
There might certain "workarounds"; such as hiding partitions; but the bitter truth is: unless you are able to some "hardware-based" write protection (that can't be disabled without destroying the drive), there is nothing you can do (see here for a similar question .. receiving similar answers).

GPU programming in java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to improve a JAVA program performances using GPU programming.
After some research on the internet I found that it is possible if i use jcuda or jocl, but the problem is that the kernel code must be written in C in both cases.
and the algorithm that i want every thread to execute is very complicated to be written in C (it does some computations to know if there will be an accident between two aircrafts) so an object-oriented language is necessery.
Is there a solution ? or must we translate the whole project to C++ ?
Thanks for your help !
Simple rule: if it needs object orientation, it looses its performance. Even if you are using GPU acceleration.
I would advise you to identify the parallel parts of your program code. You do not have to transfer all of your algorithm to the GPU device. Is there any aspect of paralellization, e.g. arrays or grids that are filled?
What kind is your simulation message exchange? Is it explicit, i.e. sending messages around your kernels, or implicit via synchronization.
You should at least give us some more information about you algorithm and its data layout.

Java CryEngine 3 [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Just a quick question, as googling it lead to not any (good) results: Can CryEngine 3 be used from within Java? And if so, would it be a good choice or not?
Currently I am trying something in jME3 (jMonkey) and it seems to be doing pretty well, only I think that CryEngine 3 should be capable of more.
As the Cryengine compiles to DLLs and you can access DLLs via the Java Native Interface. So it shouble be theoretically possible. Considering the size and complexity of the Cryengine3, I'm pretty sure they are at CryEngine 5 or 6 till you have wrapped the necessary functions of the CryEngine 3. Also calling native functions is quite expensive performancewise, so shouldn't expect any great performance. On the other hand till you are finished, processor speed will increased significantly.
Doing games with High-End graphics in Java is usally not possible. While jMonkeyEngine3 seems to be quite good, I'm sure it will not reach the quality of a good professional C/C++(/C#) Engine. When you want to get serious with game development, there are currently two options.
Learn C++ and/or C#. That are the languages usually used for larger games.
Do Browsergames. Than you can do the all the logic on the server in Java and just the presentation in flash or html5. But currently this limits you basically to 2D, because WebGL, etc. are not mature and fast enough to do a 3D game with an high end graphics.

Categories

Resources