Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.
2
votes
Accepted
Get relative path from to/from path
Performance-wise, yes, you can optimize it by going character-by-character through the input looking for / characters, such as below. …
3
votes
Finding non-bouncy numbers under 10^x
Performance
On my machine, this consistently runs marginally faster than @GentianKasa's code (3/4 of a second for k=8), assuming the same BigInteger-based framework for numbers. …
2
votes
Accepted
Two string comparison
There may be a slight performance gain to be made if the two strings are frequently equal. …
10
votes
Convert IP address to its binary representation
Note that your performance testing is flawed. The problem is the VM performs internal optimizations as it runs which can improve the performance of the system. … Also pull the System.out.println() out of your method - it's an artificial drag on the performance.
-- Working off of @rofl's other suggestion, this is 25% faster on my machine than your fast method, …
5
votes
Accepted
Downloading big PDF files
Performance
You may see some performance gain by running each file download on its own thread. You'd need to take your existing code and move much of it into a Runnable or Callable. …
2
votes
Heaping up with the inqueries
I had no problems using a SortedSet, which is both more clear and more efficient than your implementation. You should use Scanner#nextInt() instead of parsing strings yourself.
I'm currently on a Ja …
3
votes
Accepted
java : jumping caterpillar program
Maximize readability until you have a known performance bottleneck. … * This is arguably a premature optimization, and may be a performance loss if the there are many
* caterpillars and few leaves.
*/
Arrays.sort(caterpillars); …
2
votes
Accepted
Find the nearest coin to be collected in a game
The performance of LinkedList is often worse than ArrayList. You should consider testing their relative performances.
You should code to interfaces, not implementations, where possible. … As far as optimizing performance, you'll have to do some testing and see if it's working fast enough for you. …
5
votes
Accepted
Copy file using read and write streams
Streams should always be closed. You will have resource leaks if your method throws an exception. Either close the streams in a finally block, or use try-with-resources to make sure they get closed.
O …
1
vote
Accepted
Grouping items in a list into inner lists
There’s a good chance this is a big performance sink because of how much reflection you’re doing. Rather than reflect on every instance of every object, just do the reflection work once. … It might affect performance in some trivial way, but you’re better off refactoring the code to be easier to read. …
4
votes
Getting the current timestamp and compute the timestamp difference in minutes
Note that none of these suggestions will have any significant impact on the performance of your application overall. Don't micro-optimize performance until you have known, tested bottlenecks. …
4
votes
Accepted
HackerRank Sales by Match
Prefer assigning variables to the most generally applicable type. If it doesn't matter what kind of list you have, use List. If it doesn't matter what kind of map you have, use Map.
Use whitespace con …
3
votes
Accepted
custom button class for android game engine
Code should not make micro-optimizations for performance reasons until there is a clearly tested bottleneck in the code. … First use repeatable performance testing to find actual performance bottlenecks, then fix them.
Variables that are not intended to be reassigned should be marked as final. …
2
votes
Accepted
Conway's Game of Life
There are definitely performance optimizations out there. Do a search on codereview. Many will have you recreate the Cell class to track, for instance, the adjacent cells. Maybe start here? … Optimize Conway's Game of Life As always, you need to find the correct line between ease-of-comprehension and performance. Trust Knuth: premature optimizations are the root of all evil. …
3
votes
Accepted
Yet another Sieve of Eratosthenes in Java
Documentation
The class shouldn't mention who the intended client is, just what it does.
Most of your comments inside methods are noise. Document why, not what.
Error Handling
You don't handle bad inp …