I have this sort of C function -- that is being called a zillion times:
void foo ()
{
if (/*condition*/)
{
}
else if(/*another_condition*/)
{
}
else if (/*another_condition_2*/)
{
}
/*And so on, I have 4 of them, but we can generalize it*/
else
{
}
}
I have a good test-ca...
Say I have function that is called a LOT from many different places. So I would like to find out who calls this functions the most. For example, top 5 callers or who ever calls this function more than N times.
I am using AS3 Linux, gcc 3.4.
For now I just put a breakpoint and then stop there after every 300 times, thus brute-forcing ...
I have a standalone Java problem running in a linux server. I started the jvm with -Xmx256m. I attached a JMX monitor and can see that the heap never really passes 256Mb. However, on my linux system when I run the top command I can see that:
1) First of all, the RES memory usage of this process is around 350Mb. Why? I suppose this is be...
Hi,
I have simple "insert into.." query which is taking around 40 seconds to execute. It simply takes records from one table and inserts into another.
I have index on F1 and BatchID on
the tbl_TempCatalogue table
146624 records are effected.
select itself is not slow insert
into is slow.
The complete query is
insert into tbl_ItemPr...
When writing a Java program, do I have influence on how the CPU will utilize its cache to store my data? For example, if I have an array that is accessed a lot, does it help if it's small enough to fit in one cache line (typically 128 byte on a 64-bit machine)? What if I keep a much used object within that limit, can I expect the memory ...
I'm SELECTing some aggregate data and grouping on the date and a particular field. I want to display all values in that field and a count for those values even if there was no data matching that field on that day. E.g.
Date MyField Count
2009-09-25 A 2
2009-09-25 B 0
2009-09-24 A 1
2009-09-24 B ...
I've been having this memory leak issue for days and I think I have some clues now. The memory of my java process keeps growing but yet the heap does not increase. I was told that this is possible if I create many threads, because Java threads uses memory outside of the heap.
My java process is a server type program so there are 1000-20...
My inner loop contains a calculation that profiling shows to be problematic.
The idea is to take a greyscale pixel x (0 <= x <= 1), and "increase its contrast". My requirements are fairly loose, just the following:
for x < .5, 0 <= f(x) < x
for x > .5, x < f(x) <= 1
f(0) = 0
f(x) = 1 - f(1 - x), i.e. it should be "symmetric"
Preferabl...
I have to parse the XML file and build objects representation based on that, now once I get all these data I create entries in various database for these data objects. I have to do second pass over that for value as in the first pass all I could do is build the assets in various databases. and in second pass I get the values for all the ...
I'm developing for iPhone, SDK 3.1. I have about 150 images that I need to display to the user for him to page through. I've copied the code from the PageControl sample from Apple but once I load it onto the iPhone the application crashes if I scroll through quickly. I tried to write some optimization to conserve memory but it doesn't...
I want to draw a graph that will be something like this:
You can see 3 pathes: a, b & c. How can I change position of elements (1,2,3...,9) to make long of the path as short as possible? I mean this lines should be as short as possible.
Im very interested in it becouse I am drawing a graph with question, some kind of infographic like...
Hi
I am doing question 12 of project euler where I must find the first triangle number with 501 divisors. So I whipped up this with Haskell:
divS n = [ x | x <- [1..(n)], n `rem` x == 0 ]
tri n = (n* (n+1)) `div` 2
divL n = length (divS (tri n))
answer = [ x | x <- [100..] , 501 == (divL x)]
The first function finds the divisors of ...
Look at this piece of code:
MessageParser parser = new MessageParser();
for (int i = 0; i < 10000; i++) {
parser.parse(plainMessage, user);
}
For some reason, it runs SLOWER (by about 100ms) than
for (int i = 0; i < 10000; i++) {
MessageParser parser = new MessageParser();
parser.parse(plainMessage, user);
}
Any ideas ...
In may Daily Job i come across this Dilemma :
"Stable System Vs Better Design"
In routine job when i am fixing some module, When i see bad design
-> Badly written code
-> Badly Written Algorithm
-> Optimization possible
I would prefer to fix these also along with issue i am fixing
But many people opposes my changes a few support...
I'm creating a table with 30-50 columns. There are about 200K of these rows. Is it recommended to store this data in separate tables? Are there performance issues when you have this many columns.
I'll explain a bit about the table. I have to store all sports games over the past 10 years (basketball, baseball, football, hockey). Fo...
Is there any advantage to conditionally defining functions in PHP? For example, if I have a script similar to this
function abc() {
...
}
function xyz() {
...
}
if (user_is_logged_in()) {
...
abc();
...
xyz();
}
else echo 'Not logged in.';
Would there be any advantage, and would it be legal, to mo...
We have weird memory leak problem with a Java process running in linux has an ever growing swap usage. So naturally we looked at the heap dump and also used a profiler to monitor it over a period of time. We found that
1) The number of threads does not grow
2) The heap usage does not grow
3) Yet the (VIRT) usage keeps growing (which ca...
I've got 100's (maybe 1000's) of products with 10-30 images of each product coming to an online store I've put together. I need to optimize the images' file sizes as much as possible without loosing image quality.
I haven't used jpegtran, jpegoptim, or any other jpeg optimizer directly but I have noticed that punypng shrinks file sizes ...
By 'empty buffer,' I mean a buffer full of zeroes.
I am searching for a faster method of accomplishing this:
int is_empty(char * buf, int size) {
int i;
for(i = 0; i < size; i++) {
if(buf[i] != 0) return 0;
}
return 1;
}
I realize I am searching micro optimization unnecessary except in extreme cases, but I know a faster method ...
Possible Duplicate:
Checking for string contents? string Length Vs Empty String
In .NET, which is best,
if (mystring.Length == 0)
or
if (mystring == string.Empty)
It seems that these would have the same effect, but which would be best behind the scenes?
...