In addition to original balls and baskets problem I mentioned here : http://stackoverflow.com/questions/1948311/balls-and-baskets-problem-algorithm
There is a slightly different problem.
Still there are N people and they have unlimited balls but they dont have baskets this time.
Problem is :
There are N people with unlimited balls an...
Hi all,
On a mailing list I'm subscribed to, two fairly knowledgeable (IMO) programmers were discussing some optimized code, and saying something along the lines of:
"On the CPUs released 5-8 years ago, it was slightly faster to iterate for loops backwards (e.g. for (int i=x-1; i>=0; i--) {...}) because comparing i to zero is more effi...
Does the following seem normal for a histogram on an index?
Histogram Steps
RANGE_HI_KEY RANGE_ROWS EQ_ROWS DISTINCT_RANGE_ROWS AVG_RANGE_ROWS
2264548 0 1 0 1
2302473 36550 1 36550 1
2303523 767 1 767 1
2383218 77051 1...
Hi,
Recently I've been doing quite a big project with php + mysql. And now I'm concerned about my mysql. What should I do to make my mysql as optimal as possible? Tell everything you know, I'll be really very grateful.
Second question, I use one mysql query per page load which takes information from mysql. It's quite a big query, becau...
How big does a buffer need to be in Java before it's worth reusing?
Or, put another way: I can repeatedly allocate, use, and discard byte[] objects OR run a pool to keep and reuse them. I might allocate a lot of small buffers that get discarded often, or a few big ones that's don't. At what size is is cheaper to pool them than to real...
How long does it take to declare a variable in C, for example int x or unsigned long long var? I am wondering if it would make my code any faster in something like this.
for (conditions) {
int var = 0;
// code
}
Would it be faster to do this, or is it easier not to?
int var;
for (conditions) {
var = 0;
// code
}
Tha...
I am making a drawing application and I want make my code more readable and more efficient in the sense that I want the code to end up being faster and more responsive and lightweight. If you could lead this noob in the right direction then that would be wonderful.
...
I have a hash table that I want to store to disk. The list looks like this:
<16-byte key > <1-byte result>
a7b4903def8764941bac7485d97e4f76 04
b859de04f2f2ff76496879bda875aecf 03
etc...
There are 1-5 million entries. Currently I'm just storing them in one file, 17-bytes per entry times the number of entries. That ...
I'm fairly new to OpenCL so please bear with me.
In the first iteration of my code, I used basic memory buffers for large datasets and declared them global. However now that I'm looking to improve the timing, I wanted to use texture memory for this. In the CUDA version, we use cudaBindTexture and tex1Dfetch to obtain the data for a larg...
Hi I am writing 3D modeling app and I want to speed up rendering in OpenGL. Currently I use glBegin/glEnd which is really slow and deprecated way. I need to draw very fast flat shaded models. I generate normals on CPU every single frame. This is very slow. I tried to use glDrawElements with indexed geometry, but there is problem in norma...
What requires the most CPU:
int foo = 3;
or typecasting it to an unsigned int?
unsigned int foo = 3;
...
I know many will call this micro optimizing, yes it is that but it is also good to know things like this. Now my question, in my first example below you will see I have a variable set that contains a mysql query then I have another line that runs a function with the above variables mysql query. In my 2nd example I do it all in 1 line, ...
I have developed an application using Django and everything is working fine but I don't know what's going on behind the scenes. I would like to know:
How many times the database is being hit for each request?
What was the execution time for each query?
How long it took to render the template?
Regular profiling info (ncalls, tottime per...
Find a vector x which minimizes c . x subject to the constraint m . x >= b, x integer.
Here's a sample input set:
c : {1,2,3}
m : {{1,0,0},
{0,1,0},
{1,0,1}}
b : {1,1,1}
With output:
x = {1,1,0}
What are good tools for solving this sort of problem, and examples of how to use them?
...
I was wondering if anyone knows the growth policy of ArrayList in Java 1.6? The java doc says
The details of the growth policy are not specified beyond the fact that adding an element has constant amortized time cost.
But I just wonder the details because I know the size I'm targeting to start but I want to make sure I'm making th...
Dears,
I need your help to optimize the query below. Let us assume we have a web application for articles. The software use two table;one is the article table and the second one is the users table. The article table hold the date when the article is created,the id,the body,the title & the section. Let us assume that we have one section ...
Hi guys,
I have HDF5 files with multiple groups, where each group contains a data set with >= 25 million rows. At each time step of simulation, each agent outputs the other agents he/she sensed at that time step. There are ~2000 agents in the scenario and thousands of time steps; the O(n^2) nature of the output explains the huge numbe...
I'm building a online font previewer, with following architecture. I wrapped preview creation function in a standalone .py file and making system calls to it in a Django view in order to run them in parallel and maximum performance on multi-core CPU system.
preview.py
....
def make_preview(text, fontfile, imagefile, fontsize=30):
t...
Hello, I am looking for an extremely small way of turning a string like "123" into an integer like 123 and vice-versa.
I will be working in a freestanding environment. This is NOT a premature optimization. I am creating code that must fit in 512 bytes, so every byte does actually count. I will take both x86 assembly(16 bit) and C code t...
I am having some trouble with IEEE floating point rules preventing compiler optimizations that seem obvious. For example,
char foo(float x) {
if (x == x)
return 1;
else
return 0;
}
cannot be optimized to just return 1 because NaN == NaN is false. Okay, fine, I guess.
However, I want to write such that the ...