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
vote
4answers
168 views

Efficient way of evaluating an array of strings then add to an array in Ruby

I am looking for an efficient way of evaluating an array of strings against a series of rules and then adding them to another array. For example I have an array of strings: something a 1234 #gohere ...
3
votes
1answer
533 views

Benefits of setting PHP memory_limit to lower value for specific PHP script?

I need to execute just few lines of PHP code on every single page of my website. This PHP code does not require more than 4MB memory. That is why i want to allocate just 4MB memory to all pages by ...
3
votes
5answers
251 views

Premature optimization in deciding how to optimize?

We have a class that has been properly identified for optimization. We've done the profiling and testing, and it's a problem. Now we have two possible approaches for optimizing this class: There is ...
3
votes
3answers
183 views

Are there algorithims for polling optimization?

I have a web-application with an async HTTP backend, which gets called by the client by AJAX requests. The client has to start a job and then polls for the result. I started with a simple 150ms ...
0
votes
1answer
367 views

Sum of divisors of numbers of the range ~ 10^6

I was trying to find the sum of divisors of numbers upto 106. The test cases are like of the order of 105. I have done some pre processing like int divisors(int num) { int sum=0; for(int ...
10
votes
7answers
404 views

When to start thinking about scalability? [closed]

I'm having a funny but also terrible problem. I'm about to launch a new (iPhone) app. It's a turn-based multiplayer game running on my own custom backend. But I'm afraid to launch. For some reason, I ...
0
votes
1answer
337 views

Python — Time complexity of built-in functions versus manually-built functions in finite fields

Generally, I'm wondering about the advantages versus disadvantages of using the built-in arithmetic functions versus rolling your own in Python. Specifically, I'm taking in GF(2) finite field ...
5
votes
2answers
326 views

Structuring Access Control In Hierarchical Object Graph

I have a Folder entity that can be Moderated by users. Folders can contain other folders. So I may have a structure like this: Folder 1 Folder 2 Folder 3 Folder 4 I have to ...
3
votes
2answers
1k views

Are unused CSS rules so costly that they must be removed?

I have been reading various Web application optimizing articles and many of them suggest to remove unused CSS rules. Currently, I have a page which has jQueryUI css, Bootstrap CSS, Datatables CSS and ...
7
votes
3answers
355 views

Change of the complexity class through compiler optimization?

I am looking for an example where an algorithm is apparently changing its complexity class due to compiler and/or processor optimization strategies.
0
votes
4answers
125 views

Use functions inside a loop declaration

What's the best practice? This : for ($i = 0; $i < count($array); $i++) { //stuff } Or, what I usually do : $count = count($array); for($i = 0; $i < $count; $i++) { //stuff } Is it the ...
2
votes
2answers
110 views

Find common functionalities or functions between 2 programs

I've been facing a problem recently, in which I want to optimize two programs. For that, I wanted to create some kind of "Common Interface" which I could reuse between my two programs. However, the ...
1
vote
0answers
246 views

Optimization algorithm, how to develop this problem

I have a situation where I would like your input and think over / solve algorithm. The specs There are inventories with a specified amount of capacity. 'X (width) and Y (time)' creates ...
11
votes
6answers
910 views

Jargon to describe unnecessary running of code? [closed]

Some code works but it runs an unnecessarily large fraction of the code in many cases, though that extra code is still required sometimes. Better preprocessing, simple stoppers and conditional ...
1
vote
4answers
249 views

Write then optimise or write optimised [duplicate]

Do you write your code then optimise it? Or do you write an optimised code from the beginning. I always believe in writing optimised since I really dont like to rewrite code, But please share your ...
3
votes
2answers
1k views

Which code is better for branch prediction optimization?

Given branch prediction, and also the effect of compiler optimizations, which code tends to offer superior performance? Note that bRareExceptionPresent represents an uncommon condition. It is not the ...
2
votes
3answers
245 views

Implicit optimization versus explicit optimization

To explain what I mean, let me start with an example. Consider a deque that supports O(logn) concatenation with another deque and O(n) addition of n elements at one end. This dequeimplements a ...
-2
votes
1answer
520 views

using ant colony algorithm to create cross word game [closed]

I have difficulty to learn about ant colony algorithm (ACO), I have read about generating crossword game using (genetic algorithm) GA.I Know both of GA ant ACO usually used for optimization, but my ...
4
votes
2answers
1k views

Performance and other issues with using floating point types in C++

Being interested in C++ performance programming there is one aspect I really have no clue about- and that is the implications of using floating point calculations vs doubles vs normal integer ...
3
votes
1answer
146 views

Can profiling be used to verify if optimization was successful?

I know that profiling is useful to identify bottlenecks and determining what parts of the code require how much time to execute. The latter isn't always very easy to track in the midst of other paths ...
4
votes
2answers
195 views

How can I plan optimization tasks in Scrum?

Recently my Scrum team has received several requests for optimizing certain parts of our code. Looking at the software with a profiler found some spots where the code could be improved. We agreed to ...
2
votes
1answer
114 views

Turning n-dim points into m-dim where m<n and where point-to-point distance deviation is minimized

I want to apply k-means clustering to a (sparse) adjacency graph. For this I need to assign the nodes to a position in an euclidean space. Trivially I can do this by having a space with as many ...
4
votes
4answers
229 views

What performance topics should I be aware of? [closed]

When coding performance-critical portions of code (not necessarily large, but code that gets executed a lot), what topics should I be aware of/take into account. I'm already fairly familiar with ...
3
votes
1answer
71 views

Expensive AOT Optimizations

I've seen it stated several times that AOT can run some more expensive optimizations that take too long to be used by a JIT. But I've never seen it stated what exactly these optimizations are. So I'm ...
4
votes
3answers
657 views

Is it conceivable to have millions of lists of data in memory in Python?

I have over the last 30 days been developing a Python application that utilizes a MySQL database of information (specifically about Norwegian addresses) to perform address validation and correction. ...
0
votes
5answers
321 views

Is comparing an OO compiler to a SQL compiler/optimizer valid?

I'm now doing a lot of SQL development at my new job where as before I was doing Object Oriented desktop app stuff. I keep running across very large scripts (thousands of lines) and wanting to ...
5
votes
4answers
490 views

Designing a Database Application with OOP

I often develop SQL database applications using Linq, and my methodology is to build model classes to represent each table, and each table that needs inserting or updating gets a Save() method (which ...
2
votes
1answer
4k views

Most efficient Implementation a Tree in C++

I need to write a tree where each element may have any number of child elements, and because of this each branch of the tree may have any length. The tree is only going to receive elements at first ...
1
vote
6answers
1k views

Can I get a C++ Compiler to instantiate objects at compile time

I am writing some code that has a very large number of reasonably simple objects and I would like them the be created at compile time. I would think that a compiler would be able to do this, but I ...
2
votes
4answers
1k views

Is using a bigger buffer useful?

I use buffer for quite a long time when I need to copy a stream or read a file. And every time I set my buffer size to 2048 or 1024, but from my point of view a buffer is like a "bucket" which ...
1
vote
4answers
326 views

When should code favour optimization over readability and ease-of-use?

I am in the process of designing a small library, where one of my design goals is that the API should be as close to the domain language as possible. While working on the design, I've noticed that ...
1
vote
2answers
585 views

Registration: Email hash and verifying only one account per email

I'm using a registration function that hashes the email in PBKDF2 with a random and unique Salt each time. The hashes email and his salt are saved in the DB. No problem with that. The problem is that ...
1
vote
3answers
287 views

Allocation problem identification

I have a matrix. I have a list of people who have to occupy n1,n2,n3 etc cells, different number of cells in different rows. I have to place the people in the cells. Occupying the same cell across ...
37
votes
14answers
10k views

How have languages influenced CPU design?

We are often told that the hardware doesn't care what language a program is written in as it only sees the compiled binary code, however this is not the whole truth. For example, consider the humble ...
2
votes
1answer
99 views

For Which Kind of Cache will this Program not run well? How can it be optimized?

Consider the following code fragment: int a[8192], b[8192], c[8192]; int i; for(i = 0; i < 8192; i++) c[i] = a[i] + b[i]; For what kind of cache will this program not run well (set ...
2
votes
1answer
451 views

Is Google's Page Speed not working fine?

I've been making small improvements to a public ASP.NET site that I have and have ran it through Google's online Page Speed several times. I have a specific problem, but something that really threw me ...
3
votes
4answers
376 views

Does it still make sense to think about effective code on micro scale in C++?

Early in my programming career I was in love with pointer twiddling, lean code, doing everything with as little layers of abstraction as possible and so on. The code was very C like I would say, close ...
15
votes
4answers
753 views

Can applications affect power consumption in a substantial way?

Is there anything that can be done for a single general purpose application to affect the power consumption of the device it is running on? I am not familiar with how optimizations to individual ...
3
votes
1answer
1k views

Rails application - how to optimize/reduce database calls when iterating over a collection

What's the best way to optimize a Rails app where you need to pull info from the database for a collection of items? For example, if I am building an online forum system... I would have a number of ...
6
votes
1answer
318 views

Mobile cross-platform SDK for computationally intensive apps

I am aware of the PhoneGap toolkit for creating mobile applications for virtually all mobile platforms with a significant market share. However, the code in PhoneGap that is shared between the ...
2
votes
2answers
178 views

Better way to search for text in two columns

Here is the scenario. I am making a custom blogging software for my site. I am implementing a search feature. It's not very sophisticated - basically it just takes the search phrase entered and runs ...
4
votes
1answer
428 views

How to get experience in large scale databases?

I have written applications that are very small scale and the code I write works fine for them. But I have often wondered how the server side code I write would scale up from 100s of queries per day ...
4
votes
1answer
512 views

Research topics for starting and optimizing a high-traffic website

I bury a good deal of my ideas for fear that I don't know enough about scaling web applications and high-traffic websites. That said, I'd like to know of any general topics to research in order to ...
1
vote
1answer
379 views

Minimizing use of paper

I've recently faced this problem in a dynamic programming curriculum, and I honestly have no idea about how to determine the appropriate state. You're given N (1 <= N <= 70) paragraphs and M (1 ...
1
vote
3answers
3k views

Big O(n log n) and Quicksort number of operations

I have an Array with 1,000,000 unsorted elements. I need to calculate expected number of operations that needs to be performed to sort array using Quicksort algorithm in common situations (not the n^2 ...
1
vote
1answer
474 views

Optimize strategies for xml parsing?

I am looking for general optimization tips and guidelines for xml parsing. One of the optimization strategies is of course selecting the "right" parser. A detailed comparison between the available ...
70
votes
19answers
5k views

Is it ok to replace optimized code with readable code?

Sometimes you run into a situation where you have to extend/improve some existing code. You see that the old code is very lean, but it's also difficult to extend, and takes time to read. Is it a good ...
0
votes
1answer
244 views

FxCop / Code Analysis with VS2010 Ultimate

I've getting some information about this, but I still can find a proper answer, I was asked recently in my company for this : "run a fxcop analysis on that code and tell me the results". Ok, I have ...
7
votes
1answer
307 views

How fast should a web response be?

I've heard a few times that every extra [number1] milliseconds it takes to process a web request and return a response will lose you [number2] percent of users. Is this just "conventional wisdom," or ...
7
votes
6answers
2k views

Software Optimization vs. Hardware Optimization - what has the bigger impact?

I was wondering how software optimization and hardware optimization compare when it comes to the impact they have on speed and performance gains of computers. I have heard that improving software ...