optimization

Java API Method Run Times

Is there a good resource to get run times for standard API functions? It's somewhat confusing when trying to optimize your program. I know Java isn't made to be particularly speedy but I can't seem to find much info on this at all. Example Problem: If I am looking for a certain token in a file is it faster to scan each line using stri...

How to optimize this algorithm?

I have two sets of arrays like this for example. $Arr1['uid'][]='user 1'; $Arr1['weight'][]=1; $Arr1['uid'][]='user 2'; $Arr1['weight'][]=10; $Arr1['uid'][]='user 3'; $Arr1['weight'][]=5; $Arr2['uid'][]='user 1'; $Arr2['weight'][]=3; $Arr2['uid'][]='user 4'; $Arr2['weight'][]=20; $Arr2['uid'][]='user 5'; $Arr2['weight'][]=15; $Arr2['ui...

How to index a date column with null values?

How should I index a date column when some rows has null values? We have to select rows between a date range and rows with null dates. We use Oracle 9.2 and higher. Options I found Using a bitmap index on the date column Using an index on date column and an index on a state field which value is 1 when the date is null Using an index...

Why doesn't g++ pay attention to __attribute__((pure)) for virtual functions?

According to the GCC documentation, __attribute__((pure)) tells the compiler that a function has no side-effects, and so it can be subject to common subexpression elimination. This attribute appears to work for non-virtual functions, but not for virtual functions. For example, consider the following code: extern void f( int ); class ...

Lucene.Net memory consumption and slow search when too many clauses used

I have a DB having text file attributes and text file primary key IDs and indexed around 1 million text files along with their IDs (primary keys in DB). Now, I am searching at two levels. First is straight forward DB search, where i get primary keys as result (roughly 2 or 3 million IDs) Then i make a Boolean query for instance as foll...

With (or similar) statement in JQuery

Very simple question: I want to optimize the following jQuery code with maximum readability, optimal performance and minimum fuss (fuss = declaring new variables etc): $(".addthis_toolbox").append('<a class="addthis_button_delicious"></a>'); $(".addthis_toolbox").append('<a class="addthis_button_facebook"></a>'); $(".addthis_toolbox").a...

Will this DateTime optimization cause localization problems? Will it be more efficient? Is it worth it?

I'm working on updating a project which uses the following code to place a file in a folder based on the date: int month = DateTime.Now.Month; string zero = (month < 10) ? "-0" : "-"; string folder = "Folder" + DateTime.Now.Year.ToString() + zero + month.ToString() + "\\"; if (!Directory.Exists(folder)) { Directory.CreateDirectory(fo...

Which are the best LGPL Libraries for Numerical Methods, Optimization Techniques, DOE, Sensitivity Analysis?

I wish to perform some mathematical operations including Design of Experiments, Optimization Techniques, Sensitivity Analysis and Six-Sigma based Robust design for Aerospace Design project. I am developing applications for mechanical design engineers. I understand there are a few libraries like DAKOTA from sandia national labs that help...

How to write optimized queries in MySQL ?

Are there any guidelines to write the optimized queries in MySQL ? ...

2D OpenGL scene slows down with lots of overlapping shapes

I'm drawing 2D shapes with OpenGL. They aren't using that many polygons. I notice that I can have lots and lots of shapes as long as they don't overlap. If I get a shape behind a shape behind.... etc.. it really starts lagging. I feel like I might be doing something wrong. Is this normal and is there a way to fix this (I can't omit rende...

Random array special

how make special random array. i have array(1=>35,2=>25,3=>40). how make possibility that array show special elements. Ex. If i want get 100 elements from array. it will be 35/100 +-10 - must bee 1 element, 25/100 +-10 = must be 2 element, 40/100 +-10 - must be 3 element. Elements must be random, but most elements +-10. i know its pos...

How many times should a loop be unwinded?

I'm learning about loop unrolling to avoid stalls caused by dependencies. I found many examples on internet and in literature, but I found no explanation on how the algorithm used to obtain the optimized code works (in case there is one such algorithm, of course). In particular, I don't know how to determinate how many times should the l...

long oracle query

Hi there, I've got really long and complicated query(Oracle 10g). It contains about ten select subqueries. The query works but it's too long. Should I somehow divide this query? I mean is there some standard how long/complicated could sql query be. The query works but it doesn't seem to me like the best solution. For example one subquery...

MySQL query not taking advantage of index

I was analizing a query (working on a wordpress plugin named nextgen gallery), this is what I got query: EXPLAIN SELECT title, filename FROM wp_ngg_pictures wnp LEFT JOIN wp_ngg_gallery wng ON wng.gid = wnp.galleryid GROUP BY wnp.galleryid LIMIT 5 result: +----+-------------+-------+-------...

Faster way of finding multiple of double

If have the following C function, used to determine if one number is a multiple of another to an arbirary tolerance #include <math.h> #define TOLERANCE 0.0001 int IsMultipleOf(double x,double mod) { return(fabs(fmod(x, mod)) < TOLERANCE); } It works fine, but profiling shows it to be very slow, to the extent that it has become a...

HUGE framerate difference between release/debug builds

I'm working on a DirectX game and I'm finding that during release builds I'm getting 170fps average, however in debug builds I'm getting ~20fps. I was wondering if this massive difference is normal between release and debug builds especially since in debug I don't have any traces being out put? I know there hsould be a performance gap b...

Building SEO-friendly URLs for accented characters

Hello all, We are making our site an SEO-friendly site by following the pattern below: http://OurWebsite.com/MyArticle/Math/Spain/Glaño As you see, Glaño has a spelling character that search engines may not like it. On the other hand we cannot build up the last URL! Any suggestions to maintain our current URL generation code to hand...

how to improve the performance??

i had prepared a project on making a software application. It is complete and working fine except that the speed of execution is very slow..i have taken several chunks of code and optimized it.. i tried psyco..ie i installed psyco and added two lines on the top of my code import psyco psyco.full() Don't know whether this is the way usi...

How to optimize this mysql query - explain output included

This is the query (a search query basically, based on tags):- select SUM(DISTINCT(ttagrels.id_tag in (2105,2120,2151,2026,2046) )) as key_1_total_matches, td.*, u.* from Tutors_Tag_Relations AS ttagrels Join Tutor_Details AS td ON td.id_tutor = ttagrels.id_tutor JOIN Users as u on u.id_user = td.id_user where (ttagrels.id_tag in (210...

Will the Java optimizer remove parameter construction for empty method calls?

Suppose I have code like : log.info("Now the amount" + amount + " seems a bit high") and I would replace the log method with a dummy implementation like : class Logger { ... public void info() {} } Will the optimiwer inline it and will the dead code removal remove the parameter construction if no side effects are detected? ...