Optimization is the process of improving an existing program to make it work more efficiently or/and using less resources.
2
votes
4answers
78 views
How does a query execution plan affect query execution?
I have read some articles on SQL Server query optimization. The point I get is SQL Server generates a query execution plan for each stored procedure when it's executed for the first time. Those ...
0
votes
1answer
37 views
python snippet optimization explanation
I'm attempting optimize and figure out why for input n a function I wrote f(n) appears to never finish executing when n > 26.
TL;DR
I need to figure out how to find the complexity of various python ...
0
votes
0answers
52 views
Using counter or constant for parameter position
Suppose that I have the following Java code:
int i = 0;
PreparedStatement statement = con.prepareStatement("SELECT * FROM table " +
"WHERE field1 = ?, field2 = ?, field3 = ?...");
...
1
vote
1answer
66 views
Recieving errors without engaging in excessive communication when using sockets
I'm currently writing a program that communicates with a server over TCP sockets. I originally planned for the communication to include a message confirming successful communication at the end of ...
2
votes
3answers
135 views
Is denormalising a data structure essentially a code optimisation, to which the normal rules apply?
One of Bloch's Effective Java items 55: Optimize judiciously extends Jackson's rules on optimization:
Rule no. 1: Don't optimise!
Rule no. 2 (for experts): Don't optimise yet!
Extra ...
0
votes
1answer
134 views
Approaching Particle Swarm Optimization with optimization problem, how to use PSO with it?
I am learning Particle Swarm Optimization.
The problem is to find the pair of number whose sum is lowest.
Lets say we have some numbers z1,z2,z3,z4
Number Value
z1 -2
z2 -3
z3 3
...
0
votes
0answers
73 views
Decision making algorithm
I'm currently solving an optimisation problem of my own design, just to experiment and learn a little something.
Here's the concept:
I have a user that starts at home. The objective of this user is ...
0
votes
1answer
132 views
Are there compilers which optimize the use of mathematical functions?
Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathematical assumptions?
For instance in cases like
unsigned int i,b;
(i,b not ...
0
votes
3answers
76 views
How to optimize iterable queries with external arguments
I will use C# here as an example, but my question is about any language.
My question is from framework to compiler perspective (i.e the solution can be by implementing given idea inside compiler)
...
0
votes
2answers
153 views
Optimization problem where to start, what algorithms to use? [closed]
I have an optimization problem and I was wondering where to start from to be able resolve it. I think it can be solved with an NP-complete algorithm but I am not sure where to start from. The problem ...
2
votes
1answer
108 views
Improving sampling algorithm
I am having a bit of trouble designing a new feature at the moment. It is part of a resource management system. I was wondering if anyone has experience doing anything similar.
I'll try to explain:
...
3
votes
3answers
89 views
What can qualify for potential tail call recursion (TCO) optimization or tail recursion elimination (TRE)
Short question is: what can qualify for potential tail call recursion optimization (TCO) or tail recursion elimination (TRE) if the compiler or interpreter supports it.
The summary of this question ...
2
votes
0answers
79 views
Program to select N integers with constraints [closed]
I need to write a program which takes 4 inputs as follows
N = The number of integers to be generated (10 < N < 10000)
Start = The minimum value of the integers (100 < Start)
End = The ...
2
votes
1answer
107 views
Maximizing Value and Volume, minimizing weight - Knapsack
Trying out a Knapsack variant where the rules are
Any item you take must fit completely in the bag
Usable metrics of the bag are length(l),width(w),height(h) and you can assume that if the products ...
3
votes
1answer
130 views
How to safely and cheaply delete a directory's contents that are constantly being deleted/overwritten
I'm coding something that will check a specific static location's directory, and if it exists, and a certain process has not run in n minutes, it deletes that directory's files and all sub-directory ...
5
votes
1answer
229 views
Combinatorial Optimization: Filling a Bag with Sand
I have an interesting "real-world" combinatorial optimization problem that I need to solve programmatically, however I have yet been able to whiteboard a good strategy.
The task is similar to the ...
-1
votes
1answer
98 views
Sorting an array based on another array's order, quickly [closed]
There are two arrays of maps. The first array contains maps of ID values in a specific order (but not necessarily either pure ASC or DESC ordering):
// pseudo code
first := [
{"id": 1},
...
0
votes
1answer
111 views
Optimization: How much time saved is considered worth it? [closed]
I was reading up about branch predictions and cache misses, and have decided to read what every programmer should know about memory. But I'm not sure how much low level knowledge do I need to have to ...
0
votes
1answer
67 views
Multiple variable assignment vs HashTable lookup
I'm writing a CUIT ( Coded UI Test ) and I'm replacing variables with data fetched from a csv.
Example:
this.UIMap.IDBParams.UITboxFsEditText = TestContext.DataRow["num_fs"].ToString();
...
0
votes
1answer
105 views
storing single character value use string or int C# [closed]
While storing single character value for the purpose of status, gender, delete_flag etc. which is better data type string or int. Suppose ::
status = A/I or status = 1/0
gender = M/F or gender = 1/0
...
2
votes
2answers
186 views
Do nested conditionals have a significant performance impact? [duplicate]
This is a question that lives in my mind from a long time.
Does the use of multiple nested conditional statements impact the performance of a taken code? So far I know that programmers have created a ...
3
votes
0answers
126 views
How to distribute a number of elements in a bucket so that it is within a range?
I have 50 elements n1, n2, n3, ... , n50 and a limited number of buckets, say 5 buckets and each bucket can hold a range from, say 100 to 150 only (which is nothing but the sum of the elements in that ...
1
vote
0answers
40 views
Cost of cache coherency/sharing data across multiple cores?
If I have two CPU cores, one is writing a particular cache line and the other core wishes to
Read
Write
the same cache line, what are the costs (in cycles) for doing so?
I am a little unsure ...
3
votes
3answers
75 views
Premature memoization on obvious cases
In the code below there will be several instances of MainClass.
class MainClass(object):
def f(self, x):
# expensive operations.
# ...
return 'something'
Each instance ...
1
vote
3answers
2k views
Linking two or more different programming languages
I would like to ask how optimizer software written in C/C++ can be linked to simulator software written in FORTRAN or any other language. I have copied the section of journal article of Singh and ...
4
votes
2answers
83 views
How do you avoid dominant solutions in multi-objective simulated annealing?
Imagine an RPG game were you can cary N items, and you want to maximise your damage, attack speed and armour, given a set of items.
I implemented simulated annealing where a permutation simply ...
0
votes
0answers
52 views
Microcontroller oLED Display Buffering Optimizations or Alternatives For Speed?
I'm developing a UI/Layout for a 128 x 64 oLED Monochrome Pixel Display. I've got a small netMF microcontroller driving the display via SPI at 40mhz.
I'm using some basic methods, like these here, to ...
5
votes
5answers
305 views
Can a pimpl variation be implemented without any performance penalty?
One of the issues of pimpl is the performance penalty of using it (additional memory allocation, non-contiguous data members, additional indirections, etc..). I would like to propose a variation on ...
0
votes
1answer
85 views
Optimizing instant notifications
Scenario
To deliver instant notifications to the client, I'm sending an AJAX request to a PHP page that checks if there are new notifications: if there are, it outputs them, otherwise it sleeps for ...
3
votes
1answer
108 views
Can fast, optimized server calls collapse a server?
I've followed a series of optimizations to make our APIs faster. We microoptimized a lot of PHP code to faster, native methods, we unsed variables where they were not being used anymore, and basically ...
9
votes
3answers
2k views
My algorithm that extracts the largest box that can be made from smaller boxes, is too slow
Imagine a cube based world (such as Minecraft, Trove, or Cube World) where everything is made up of identically sized cubes and all the cubes are of the same kind.
The goal is to represent the world ...
3
votes
2answers
93 views
Reducing a sequence of array modification operations (insert, sort, replace, remove)
Given a plain array of values, e.g.
["Apple", "Orange", "Banana", "Strawberry"]
and a list of operations from the set of [insert, delete, sort and replace], e.g.
[
{cmd: "insert", index: 2, ...
3
votes
2answers
307 views
Work out which parcel deliveries we ship ourselves and which we outsource
Firstly, I hope I'm asking this in the right place. I work for a large online retailer in UK. We ship approaching 2000 orders each day and are growing very quickly.
We currently use multiple delivery ...
0
votes
0answers
44 views
Approaches to combinatorial optimization problem
Problem
I have the following combinatorial optimization problem:
A set of applications need to be distributed among a set of nodes.
Each node has a capacity and each application has a required ...
0
votes
0answers
25 views
Feasible solution on the constructions phase of GRASP
I am learning about the GRASP (Greedy Randomized Adaptive Search) meta-heuristics.
From what I understood, GRASP is based on two main phases.
The first one:
Construct a initial solution based on ...
3
votes
1answer
76 views
Is serving a single document from a server to a browser slower than serving multiple documents?
I was looking into how to optimize web pages and the biggest way (code-wise) to optimize a website is to reduce the number of requests a browser has to make to your web server to get the full page.
...
6
votes
2answers
184 views
Algorithm for comparing hundreds of similar, but not identical documents
I have seen similar questions about text comparison, but none on such a large scale.
I have a client with two sets of recordings of speeches, 250 and 550 recordings each. Each of the recordings in ...
2
votes
0answers
50 views
Optimizing trigram look ups with wildcards
I am working on creating a spell-checking service for Android (note: this is a platform- and language-neutral question) for Asturian, a minority Romance language. We're using hunspell as the base but ...
0
votes
0answers
114 views
Does loop unrolling on a JIT platfrom (.NET or JVM) provide any benefit
I know in C, you can use loop unrolling (unwinding) to help reduce branching in your code but at the expense of program size. That seems to work when you compile to a target machine, however, does it ...
13
votes
1answer
236 views
Why is Haskell unable to avoid repeated evaluation without the monomorphism restriction?
I just finished learnyouahaskell the other day, and I was trying to make sense of the Monomorphism Restriction, as described by the Haskell Wiki. I think I understand how the MR can prevent repeated ...
0
votes
0answers
281 views
Android runtime - does ART miss optimization opportunities over Dalvik?
Is ART a strict improvement over Dalvik, or there are optimizations that an ahead-of-time compiler will miss compared to JIT, but Google decide they don't matter in practice?
For example, with JIT, ...
6
votes
6answers
713 views
performance versus reusability
How can I write functions that are reusable without sacrificing performance? I am repeatedly coming up against the situation where I want to write a function in a way that makes it reusable (e.g. it ...
12
votes
2answers
570 views
Ant colony algorithm
I am a student working on an ant colony simulator for a course project. The algorithm for it is (obviously) an ant colony algorithm. I know there are various forms of the algorithm but all of those ...
1
vote
1answer
207 views
Different Implemenations of Tail Call Optimisation
I've heard some people in my university discuss the tail call optimisation in ML as if it were a special version tail call optimisation.
Does the ML (SML/F#) implementations of tco in these languages ...
18
votes
6answers
662 views
How does branch prediction work, if you still have to check for the conditions?
I was reading the popular answer about Branch Prediction from http://stackoverflow.com/q/11227809/555690, and there is something confusing me:
If you guessed right, it continues on.
If you ...
1
vote
1answer
455 views
How to merge two functions that do same things with different variables
I have these two Javascript functions that are equal except for the variables
onClickVoteUp: function (e) {
var $target = $(e.target);
var upvoted = this.model.get("upvoted");
var ...
1
vote
2answers
178 views
Do today's modern compilers perform run time checks?
This is regarding compilers.
Do compilers perform run time dependency checks to decide to vectorize a loop ? In other words, do compilers trace through the logic as it would in run-time to ...
1
vote
0answers
74 views
A fast algorithm for a simple multi-objective minimization?
I have a set of n (arbitrary) integer numbers S which I want to partition into k subsets S_i each of size n/k (you can assume that k divides n). Let A be the arithmetic mean of elements of the set S. ...
2
votes
0answers
69 views
Loop Unfolding and Named Significant Bits
I've been writing a Parser Compiler for the last seven or so years, and I recently got to the point (yet again, never satisfied) of structuring the portion dealing with the portions of the language ...
1
vote
2answers
104 views
When, if ever, are basic concurrency optimizations generally made?
Lets say I need to preform the following computationally intensive task
For i in range(100000000):
doComplexCalculationWithNoSideEffects(i)
Most people I talk to tell me that basically any ...