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
Number pyramid in Java
Dividing the work over some helper methods with explaining names helps making the code more readable and reduces cyclometic complexity per method.
Use a StringBuilder to compose the result String, as …
2
votes
Accepted
JPanel rendering too slowly
Looks like most of the time is spent in the frame.pack() call. Replacing it with frame.setSize(222, 181); is a lot faster. I simply ran the code once with frame.pack() and added a line to output the r …
1
vote
Constructing polygons from the edges in a Voronoi diagram
To improve the speed of your code, you'd really have to profile it, and know what the bottleneck is (use a profiler, and find out in what methods most of the time is spent).
Here's what I would have …
4
votes
Accepted
Return the largest product of 2 numbers that is a multiple of 9 in O(n)
The solution will be of one of two forms :
a * b where a is divisible by 9
or
c * d where c is divisible by 3 and d is divisible by 3
To find the maximum of the first from we need to find …
1
vote
Thread safety and performance when multiple threads write into same Writer
This problem can easily be solved using the Producer-Consumer pattern. Thread A & B from your example are the producers (they produce the tasks : lines to be written to a file). A third thread C, the …
3
votes
Finding the nearest Rational to a double - is there a more efficient mechanism?
Why not simply have java.util.BigDecimal do the heavy lifting :
public Rational valueOf(double d) {
BigDecimal bigDecimal = BigDecimal.valueOf(d);
long numerator = bigDecimal.unscaledValue(). …
4
votes
Accepted
Check whether a date is a valid future date
Correctness
My first point is that the current date is accepted as a valid future date. That is odd, and it is certainly not according to :
Tests whether the date input represents a real date i …
2
votes
Accepted
Pizza ordering program recursion on the GUI
There's a lot that can be said here, but I'll keep it to the main points of attention.
Yes, some of the data is loaded from the database, but it doesn't really make any difference; how many options …