Optimization is the process of improving an existing program to make it work more efficiently or/and using less resources.

learn more… | top users | synonyms (1)

3
votes
1answer
176 views

Do compilers un-inline recurrent expressions?

Does a compiler look for recurrent expressions to convert it into 'function' to reduce binary size and improve performance? Of course, the obvious answer might be "some do it, some don't", so I ask ...
0
votes
0answers
68 views

What Algorithm can be use for task allocation based on location?

What algorithm can be use for task scheduling based on location? For example there are 100 students and 5 lecturers available. Each lecturer must get same amount of student using location allocation ...
0
votes
2answers
39 views

Calculating NPath Complexity

I'm trying to calculate the NPath Complexity within a function, but I'm unsure what parts I count. My understanding is that it'll sum: If Else Else If Switch Case Default Do While Is this ...
3
votes
1answer
142 views

How do I add link-time optimization capabilities to my LLVM-based compiler?

I am designing and implementing a programming language, and I am using LLVM for native code generation. Among others, performance is a key feature of the language, and as such, I am looking to ...
7
votes
6answers
1k views

Why don't compilers inline everything? [closed]

Sometimes compilers inline function calls. That means that they move the code of the called function into the calling function. This makes things slightly faster because there's no need to push and ...
1
vote
2answers
159 views

How to measure algorithm accuracy?

I have a few optimization algorithms (for finding function minimum) and I'd like to check how good they are. Suppose I build test cases and compare the actual results to theoretical ones. What ...
2
votes
1answer
86 views

Finding a way to simplify complex queries on legacy application

I am working with an existing application built on Rails 3.1/MySql with much of the work taking place in a JavaScript interface, although the actual platforms are not tremendously relevant here, ...
1
vote
2answers
129 views

Best practices for geolocation

We are writing a flight search engine. We want to pre-fill the departure airport for mobile users with the closest one to their location. To do that, our plan is to Find a list of airports with ...
2
votes
4answers
163 views

Optimizing code by using registers, but what if they are not enough in number?

One way to optimize code is to minimize the access to arrays and use variables instead, because that way we use registers instead of loading data to cache memory. For example, if in a loop I'm going ...
4
votes
2answers
147 views

Deferred execution of Dispose for IDisposable objects

I'm working on an application that does lots of encryption and decryption in-application and this is probably the number-one bottleneck, so I've been spending some time making performance tweaks to ...
0
votes
0answers
78 views

Dynamic programming in Bin packing

Problem: Given a list L of objects of possible sizes from set S={1,2,4,8} and unlimited supply of bins of sizes 16 each and we have to use minimum possible numbers of bins to pack all objects of L. I ...
0
votes
1answer
66 views

Refactoring a Single Rails Model with large methods & long join queries trying to do everything

I have a working Ruby on Rails Model that I suspect is inefficient, hard to maintain, and full of unnecessary SQL join queries. I want to optimize and refactor this Model (Quiz.rb) to comply with ...
17
votes
3answers
368 views

How to test and optimize when you can't reproduce the environment?

In the past, I've worked in a variety of environments. Desktop apps, games, embedded stuff, web services, command line jobs, web sites, database reporting, and so on. All of these environments shared ...
4
votes
0answers
327 views

How to best implement K-nearest neighbours in C# for large number of dimensions? [closed]

I'm implementing the K-nearest neighbours classification algorithm in C# for a training and testing set of about 20,000 samples and 25 dimensions. There are only two classes, represented by '0' and ...
0
votes
4answers
382 views

File exists vs. File does not exist. Is there a difference in performance?

Let's say I am checking a directory for the existence of a file, and then depending on whether or not the file exists, I act accordingly. For example, see the two Python snippets below. if ...
3
votes
3answers
234 views

Data Oriented Design - impractical with more than 1-2 structure “members”?

The usual example of Data Oriented Design is with the Ball structure: struct Ball { float Radius; float XYZ[3]; }; and then they make some algorithm that iterates a std::vector<Ball> ...
-1
votes
1answer
100 views

get all the combination of a given set of numbers [duplicate]

I m trying to get the possible combinations of a given set of numbers say for example 123 The possible combinations would be 123 132 213 231 312 321 For this i have written a code as below - ...
1
vote
1answer
106 views

Memory read/write access efficiency

I've heard conflicting information from different sources, and I'm not really sure which one to believe. As such, I'll post what I understand and ask for corrections. Let's say I want to use a 2D ...
1
vote
1answer
80 views

Efficient algorithm for Virtual Machine(VM) Consolidation in Cloud

PROBLEM: We have N physical machines(PMs) each with ram Ri, cpu Ci and a set of currently scheduled VMs each with ram requirement ri and ci respectively Moving(Migrating) any VM from one PM to ...
1
vote
2answers
87 views

Which is more expensive multiple conditional branches or multiple relational expression in a single condition?

Which is more expensive in terms of processing costs if ( x < 20 && z == "M") { // statements 3 } if ( x >= 20 && w && x <= 65) { // statements 1 } if( x ...
1
vote
1answer
184 views

How does an optimizing compiler react to a program with nested loops?

Say you have a bunch of nested loops. public void testMethod() { for(int i = 0; i<1203; i++){ //some computation for(int k=2; k<123; k++){ ...
2
votes
2answers
209 views

Why isn't Haskell able to optimize infinite lists?

Lets say you've got a list l = [0, 2..] and you want to get the nth number when n is pretty large, say n=123456789. So you call l !! 123456789. On my machine, this results in out of memory. So why ...
16
votes
11answers
6k views

Does C++ compiler remove/optimize useless parentheses?

Will the code int a = ((1 + 2) + 3); // Easy to read run slower than int a = 1 + 2 + 3; // (Barely) Not quite so easy to read or are modern compilers clever enough to remove/optimize "useless" ...
0
votes
2answers
221 views

Optimization ended up in casting an object at each method call

I've been doing some optimization for the following piece of code : public void DrawLine(int x1, int y1, int x2, int y2, int color) { _bitmap.DrawLineBresenham(x1, y1, x2, y2, color); } After ...
2
votes
2answers
105 views

Is retaining intermediate objects as member fields a good idea in this case?

I'm currently writing a series of classes in java that are meant to translate a regular expression (written with the formal definition, not language-specific shortcuts) into a deterministic finite ...
1
vote
3answers
482 views

Is there a performance difference between ++x over x++? [duplicate]

Is there a performance difference between using ++x over x++ increment operators? I've see developers use ++x in loops where I would normally write x++ out of habit. For example; for(int x=0; x ...
0
votes
0answers
28 views

How do I implement the OpsDB from Release It! by Michael T Nygard

I have recently been reading the Release It! book by Michael T Nygard.In the book he talks about Implementing an OpsDB to manage and record performance statistics of applications. Has anyone ...
0
votes
2answers
117 views

Is it fine to reuse a class instance?

I ask in terms of high cost classes, with a particle engine as an example. I read somewhere that an instance of a class with a high cost to initialize, like a particle manager, should have its state ...
0
votes
2answers
66 views

Trying to “combine” similar objects without doing a bazillion comparisons

In this database I have "accesses" - each access can have any number (usually less than 4, sometimes as many as 15) attributes. I also have "tickets" where N users are requesting M accesses, so I've ...
0
votes
0answers
39 views

Maximize the visibility of an ad to a maximum of people in an automatic advertising system

I have N different ads that I want to display at the same time to M people in an automatic advertising system. Some people will never see some ads because they only check some specific criteria on the ...
2
votes
0answers
57 views

Performance consideration and code reduction for Templates

I'm trying to decide if this might be a good idea to help reduce the size of some of my xaml resource dictionaries on a large project. Except I'm concerned about any potential performance issues going ...
2
votes
3answers
119 views

Difference between Optimization and Scalability?

If I quote a paragraph from Wikipedia about Optimization: In computer science, program optimization or software optimization is the process of modifying a software system to make some aspect of ...
18
votes
9answers
1k views

Does OO, TDD, and Refactoring to Smaller Functions affect Speed of Code?

In Computer Science field, I have noticed a notable shift in thinking when it comes to programming. The advice as it stands now is write smaller, more testable code refactor existing code into ...
1
vote
0answers
82 views

How to identify performance bottlenecks in your software [duplicate]

I'm building an application with lots of components, a lot of which are third-party so I only know what I can get from their documentation. From time to time, by pure luck, I find out one of these ...
2
votes
2answers
198 views

Implementing bussiness logic with a large number of business rules and processes

We are currently working on a project that heavily relies on a database. Among many tables the main focus is on table "data" which is linked to another table "data_type" as many-to-one, which is then ...
0
votes
1answer
176 views

Mixing declarative & imperative code (Implicit 'unit tests' ?) [closed]

Well I'm no expert, but as a student, I'm curious about languages and their design patterns / goals. I'd like to know, whether there are any points I miss in the following examples, and why ...
3
votes
1answer
303 views

modelling a restaurant availability search

I am looking into finding an efficient way which can scale up to thousands of restaurants, for doing a reservation search. Ideally, it would be efficient to answer queries like find a restaurant ...
1
vote
1answer
155 views

Measuring “novelty” of data

I have a heuristic in mind that should allow me to "score" data based on "novelty" that I would like to work in real-ish time. In this case, I mean novelty in the sense that the data source is ...
1
vote
1answer
235 views

Next power of 2 for a number (in search for better “bit-twiddling” way)

I just wonder if there exists better (i.e. faster?) way to get the next power of 2 for a given number than the following one (maybe some better sort of "bit-twiddling" hack is possible?) ... static ...
6
votes
4answers
3k views

How do I traverse a tree without using recursion?

I have a very large in memory node tree and need to traverse the tree. Passing the returned values of each child node to their parent node. This has to be done until all the nodes have their data ...
0
votes
3answers
629 views

Unique and primary keys on a database (mysql)

I'm having quite some doubts here... If I have a table related to username/password login how can I assure there won't be any more matches of the same username and password in the same table using ...
15
votes
2answers
553 views

Algorithm for fast tag search

The problem is the following. There's a set of simple entities E, each one having a set of tags T attached. Each entity might have an arbitrary number of tags. Total number of entities is near 100 ...
0
votes
2answers
232 views

Multi regex matching — what to do to optimize it?

I have multiple regexes matching an input in greedy-first mode. All regexes are already compiled and I don't see what I can do more to speed-up things. I mean using tools coming with .Net framework. ...
3
votes
1answer
283 views

Compiler doesn't inline anything?

I've rolled my own SIMD-accelerated math library. It's gotten pretty complete, so naturally I went to conduct speed tests and optimize it. Btw this isn't premature optimization, the lib is actually ...
2
votes
0answers
157 views

Understanding velocity update in Binary Particle Swarm Optimization

I am wondering how to interpret the velocity update in a Binary Particle Swarm Optimization (PSO). To recap the velocity update : V(t+1) = V(t) + c1 * r1 * (XlocalBest - X(t)) + c2 * ...
3
votes
3answers
823 views

Ordering if conditions for efficiency and clean code [closed]

This is purely a design question and the example is simple to illustrate what I am asking and there are too many permutations of more complex code to provide examples that would cover the topic. I am ...
0
votes
1answer
168 views

What are some efficient ways to set up my environment when working on a remote site?

Hello fellow Programmers, I am still a relatively new programmer and have recently gotten my first on-campus programming position. I am the sole dev responsible for 8 domains as well as 3 small sized ...
1
vote
1answer
125 views

Optimising news fetching

I have a web scraper for scraping news from different sources in wp7. My current appraoch for doing this is: load newspapers information from xml file. go to the specified sections and fetch the ...
0
votes
1answer
232 views

How small is the footprint of a small C compiler?

This week I could optimize using a reduced C library that allowed a drastic shrinkage in code size - from about 60 K to about 6 K and then we could load the code in the 8 K on-chip memory of an FPGA ...
4
votes
2answers
335 views

Optimizing code generation for expressions in a compiler

I don't know if this question has a simple answer or not, but I just have to ask. I'm reading this tutorial (I don't know if this is a well-known series, but it's name is 'Let's build a compiler!' by ...