As Knuth said,
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
This is something which often comes up in Stack Overflow answers to questions like "which is the most efficient loop mechanism", "SQL optimisation techniques?" (and so on). The standard answer to thes...
I love to work on AI optimization software (Genetic Algorithms, Particle Swarm, Ant Colony, ...). Unfortunately I have run out of interesting problems to solve. What problem would you like to have solved?
...
Has anyone ever had code in Python, that turned out not to perform fast enough?
I mean, you were forced to choose another language because of it?
We are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it rel...
I have a function (called "powersearch", the irony!) that searches for a set of strings across a bunch(~ 5) of fields.
The words come in as one string and are separated by spaces.
Some fields can have exact matches, others should have "contains".
(Snipped for brevety)
//Start with all colors
IQueryable<Color> q = db.Colors;
//Filter ...
The server I'm trying to maintain is sassing me.
Among other things, I ran tload. This probably provides helpful information to someone who knows how to read this data. I do not.
It says:
1.36, 1.12, 0.59 -------------
What should I glean from this? This is our home-grown stat server, it gets a crap-ton of requests, and runs logr...
Hi
I am working on a matlab application for which I need much improved speed. I am using linprog to solve a 2-constraint linear program with around 10,000 variables bounded by zero and one. Linprog is extremely slow for my application. Is there any way I can reformulate to improve speed? Or do you perhaps know of some matlab-compati...
Hi,
Simple question - In c++, what's the neatest way of getting which of two numbers (u0 and u1) is the smallest positive number? (that's still efficient)
Every way I try it involves big if statements or complicated conditional statements.
Thanks,
Dan
Here's a simple example:
bool lowestPositive(int a, int b, int& result)
{
//ch...
I'm trying to write a function that is able to determine whether a string contains a real or an integer value.
This is the simplest solution I could think of:
int containsStringAnInt(char* strg){
for (int i =0; i < strlen(strg); i++) {if (strg[i]=='.') return 0;}
return 1;
}
But this solution is really slow when the string is lon...
For fun when I have time, I like to code games to see how hard it is or just because I want to see how it works from the inside or just for personal challenge. I just like coding. For now, I made these ones.
So I made a Sudoku board. First it was the normal 3x3x3 board but then someone asked me to do a 4x4x4 board. I was successful but ...
I'll say right off the bat that this question is NOT about load times; I know about YSlow, the Firebug profiler, and whatever best practices and tools googlage reveals about page component load times.
I am asking what good profiling tools or libraries or add-ons there are for measuring actual execution of Javascript (specifically jQuery...
Well I was reading this post and then I came across a code which was:
jokes=range(1000000)
domain=[(0,(len(jokes)*2)-i-1) for i in range(0,len(jokes)*2)]
I thought wouldn't it be better to calculate the value of len(jokes) once outside the list comprehension?
Well I tried it and timed three codes
jv@Pioneer:~$ python -m timeit -s 'j...
Is it better in some sense to vectorize code by hand, using explicit pragmas or to rely on or use auto-vectorization? For optimum performance using auto-vectorization, one would have to monitor the compiler output to ensure that loops are being vectorized or modify them until they are vectorizable.
With hand coding, one is certain th...
In output of explain command I found two terms 'Seq Scan' and 'Bitmap heap Scan'. Can somebody tell me what is the difference between these two types of scan? (I am using PostgreSql)
...
I have a type which I consider use it as struct.
It represents single value
It is immutable
But the problem is, it has 6 fields of int.
So which solution I should use for this type?
keep using struct?
change to class?
or pack 6 integers into an array of int, so it has only one field
EDIT
Size of struct with 6 integer fields is ...
What optimization techniques do you use on extremely large databases? If our estimations are correct, our application will have billions of records stored in the db (MS SQL Server 2005), mostly logs that will be used for statistics. The data contains numbers (mostly integer) and text (error message texts, URLs) alike.
I am interested in...
Which one of the following do you do:
var = true;
if (...) var = false;
Or
if (...) var = false;
else var = true;
Is there a reason you pick on or the other?
I'm working on the premise that nothing else is happening to var. The next line of code might be something like:
if (var) { ... }
...
I've been reading a lot lately about how joins in DB queries slow things down. Evidently Google App Engine doesn't even allow them.
I'm wondering how people design an app with no joins though. For example I'm working on an app that has contacts and organizations. A contact can be in many organizations and an organization can have many c...
I have a parts database that I am going to be constantly querying for a quoting system. The parts database has 1,400,000+ records in it. The users are just going to start typing part numbers, which they expect the system to be able to find after only a few characters, so I need to be able to do a wildcard search, something like:
SELEC...
I've been profiling an application all day long and, having optimized a couple bits of code, I'm left with this on my todo list. It's the activation function for a neural network, which gets called over a 100 million times. According to dotTrace, it amounts to about 60% of the overall function time.
How would you optimize this?
pub...
Let's say I have a table tbl with columns id and title.
I need to change all values of title column:
from 'a-1' to 'a1',
from 'a.1' to 'a1',
from 'b-1' to 'b1',
from 'b.1' to 'b1'.
Right now, I'm performing two UPDATE statements:
UPDATE tbl SET title='a1' WHERE title IN ('a-1', 'a.1')
UPDATE tbl SET title='b1' WHERE title IN ('b-1',...