Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I have a quite large Java application, that I may thinking to do some performance increase, but I am very new at this and wonder where should I start.
I guess I have to first perform some code test and see where most calculation and resource/time spend on which part of code before starting increase performance. Are there any tool that I can use and any general tips where to start and how to increase performance?
You may take a look at this:
Performance profiler for a java application
And find bottleneck of your application.
Without further info, there is not much to say. Some general advice for performance issues:
Do not put if inside loops, if it can be outside
Try avoid extensive use of division operator
Cache data instead of loading them all over again from files / DB
Recursion may be faster if rewritten to loops
If you now sizes of "lists" beforehead, no not use add, but resize your array during initialization
Use threads were possible and where thread could perform large portion (or slow) of code. Do not use threads if you only need to fill array with max of tousands elements.
First, if you have lots of loops, think carefully about whether you need to run through every single loop. Maybe you can combine some of them?
Second, don't create variables unless you have to. If you have a complex mathematical equation, write it out split up into lots of variables to make it easier to debug, but remember to combine it into one or two lines when you're finished.
Finally, use one of the many free open-source Java profilers.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Does anyone know of a library that will help me build a file store in Java? I am not looking for something like JCP. Rather, I need to build something that stores millions of files/terabytes of data, de-duped by hash, and with metadata for each file. Metadata might include mime type, filenames, dates, size, etc. (A hash might correspond to various filenames, dates, etc.)
I know this is not overly difficult, but I don't want to reinvent the wheel if the wheel already exists. For example, files have to be sorted into a directory hierarchy on disk based on part of the hash to avoid exceeding the maximum number of files the OS will allow per directory. A web service needs to be written to provide access to files, etc. Some other data structure (RDBMS?) needs to store the metadata. A mechanism is needed for loading new content.
Everything I am finding is higher level, JCP or JCP-ish, but I figured it was worth checking with the experts here before going off to build it. Thanks in advance.
Definitely don't reinvent the wheel... an RDBMS might work, but something like Apache Rabbit perhaps? If you want reaalllllyyyyy low level there is Peter Lawrey's Chronicle.
All the existing content management solutions are too high level for my purposes. SQLServer with FILESTREAM is about as close as I could find with what promises to be reasonable performance. However this is not a difficult thing to build and then I won't have to reply on a specific RDBMS for the solution, so that is the route I'm going to go with.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Which of the existing collections of data in C/C++ is the most suitable close in functionality to collection(library) Disruptor in Java?
http://lmax-exchange.github.io/disruptor/
The small description:
It is an extremely fast alternative using messaging queues in multithreaded programs. Framework which has "mechanical sympathy" for the hardware it's running on, and that's lock-free. And lots of efforts to avoid lock, CAS, even memory barrier.
Read more about it in the discussion: How does LMAX's disruptor pattern work?
If you want the same functionality, use a mutex protected queue. If you want the same performance you should re-implement the disruptor algorithm in C++ or try this open source project: https://code.google.com/p/disruptor-cpp/
And for those who don't know, the Disruptor (unfortunate name) is a message passing technique that uses lock-free algorithms and pays close attention to issues such as cache conflicts, to deliver very high performance in cases where it can be used. A company named LMAX came up with it and named it. Martin Fowler (of Refactoring fame) is an advocate for it.
Yes, there is already a functional C++ port. See https://github.com/fsaintjacques/disruptor--
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I am a university student that has been working with java now for a few years. I have been using eclipse in that time, but I have started to take a look at intellij idea. One big thing that I am interested in is battery. At most times, I am using my macbookto program. The biggest issue I have with it is trying to get the most out of the battery as using a IDE + testing programs can use quite a bit of power. Does anyone know which IDE (IntelliJ IDEA / Eclipse) would be better on the battery, or do you know any tips that could improve the battery life using either IDE?
This question will result in opinionated answers+this not about programming. There are no definite tests on finding which uses less battery power.
As Daemon said the difference in power consumption is minimal/insignificant.
What you should be asking are the objective differences between either IDE. Many people have asked that on Stackoverflow, so you should look into that. The following link shows some objective differences between the two: Differences between Eclipse and IDEA
However, IDEA does come with a Power Save Mode; not sure if that's relevant to you? From the DOCS: Power Save Mode Select this check box to minimize power consumption of your computer on account of eliminating the background operations. When Power Save Mode is on, no inspections are performed.
I suggest you carry around a battery charger.
Notepad++ makes for a functional code editor without the extra features that add processing overhead (which is likely draining your battery somewhat, but not much).
In all seriousness however, you'll find that the difference between IDE's in terms of power consumption is minuscule, and can safely be ignored. If you want to see real improvement in battery life, consider switching to a less performance-hungry operating system, such as Arch Linux.
If you're still concerned, consider stripping Eclipse or IntelliJ down to the bare minimum feature set required by your work.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm currently reading Head First Java, and I am wondering if there any websites or books? that I could go to that would set out some sort of task or assignment for me to practice on. In order to gain a better practical understanding of java. Even something like a mini project and then at the end I could see a completed solution that would show me areas I could of improved my code.
Even a Step by Step project tutorial for creating a game perhaps?
Has anyone got any resources like this?
Thanks
Code Kata is a good place to find various programming assignments, and those are not language-specific. So, there's no real "one solution" to them, but they are a good way to get you thinking about different classes of problems.
I'm pretty sure I've seen another site much like that, but can't seem to think of which one it might have been right now.
Or, if you are mthematical inclined, try Project Euler.
take a look at this site it has lots of mini project related to java
http://www.1000projects.com/new/java/mini/main.html
Java Student Projects
http://mindprod.com/project/projects.html
Example Depot is a great place for real-life java examples. Try looking at examples and combining them to create a real application.
If you want more theoretical assignments: http://www.psc-consulting.ca/fenske/cpjava.htm
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
This is along similar lines as these recent questions:
Best Java Obfuscation Application For Size Reduction
Creating non-reverse-engineerable Java programs
However, one ends up recommending yGuard and the other ProGuard but neither mention both. I wonder if we could get a comparison of each one and hear peoples experiences from both sides of the fence. Looking at this comparison chart on the ProGuard website its clearly angled towards ProGuard. But what about real-world experience of each - which one produces smaller output? which one is harder to decompile from? what Java versions are supported by each?
Personally I'm particularly interested from a J2ME point of view but please don't limit the discussion to that.
Results for my project.
Obfuscation - both fine.
Optimisation - ProGuard produced 20% faster code (for the measured app bottleneck).
Compactness - ProGuard about 5% smaller.
Configuration / Ant - YGuard is much easier to configure.
So, I'd advise ProGuard - but configuration and ant integration could definitely be improved.
Proguard is a better product; especially if you take the time to go through the settings for J2ME.
Specifically for J2ME there is a far better (commercial) product called mBooster
I've been getting around 25% improvement in size on my application after its been through Proguard. This is mainly to do with the better Zip compression on the Jar file and comprehensive support for class merging and preverification.
My opinion is - ProGuard is better. Output is smaller a bit. Optimizing is better and much faster.
Decompiling is simple in both cases. Well, i mean, if u know Java well and really know business-logic of what you're decompiling, there is no problem to get it back to sources from obfuscated classes.
So, my opinion is ProGuard is better.