optimization

Optimizing a jQuery drop-down menu function

Here's the function, which I am calling like this: $(document).ready(function(){ dropdownmenu(); }); function dropdownmenu() { $("#navigation ul li.upper").hover(function(){ $("ul.submenu", this).show(400); },function(){ $("ul.submenu", this).hide(); }); } How can I optimize this function, specifically ...

Optimizing for a smaller .cod (.jar) file

The RIM compiler performs extra optimization and compression on the resulting ".jar" while building the final .cod file, but there are things that can be done by the developer to significantly reduce the final .cod file size. One such thing would be to run PNGCrush, OptiPNG, or a similar tool to reduce the size of the included .png fil...

Delphi constant bitwise expressions

Probably a stupid question, but it's an idle curiosity for me. I've got a bit of Delphi code that looks like this; const KeyRepeatBit = 30; ... // if bit 30 of lParam is set, mark this message as handled if (Msg.lParam and (1 shl KeyRepeatBit) > 0) then Handled:=true; ... (the purpose of the code isn't really important) ...

What's the best way to implement user's preferences in this PHP app?

I have a smaller web app that republishes content from one social source to another. Users have, let's say 5 options for how to filter that content. Their prefs are stored in my user DB as 1 or 0 markers. When I do my major "publish" action hourly, what's the best way to break up my code to implement these preferences? To make it more c...

Optimizing ORDER BY Query on large table MySQL

I have a browse category query that im trying to optimize. Im ending up with Using temporary; Using filesort in the explain and the query is slow on a category with say 60,000 rows. If i remove the Order By clauses the query runs very fast .05 seconds to do 60,000 rows. With the Order By clauses its very slow around 5 seconds. Parts cont...

Optimal MySQL-configuration (my.cnf)

The following is my default production MySQL configuration file (my.cnf) for a pure UTF-8 setup with InnoDB as the default storage engine. [server] bind-address=127.0.0.1 innodb_file_per_table default-character-set=utf8 default-storage-engine=innodb The setup does the following: Binds to localhost:3306 (loopback) instead of the defa...

Is shifting bits faster than multiplying and dividing in Java? .NET?

Shifting bits left and right is apparently faster than multiplication and division operations on most (all?) CPUs if you happen to be using a power of 2. However, it can reduce the clarity of code for some readers and some algorithms. Is bit-shifting really necessary for performance, or can I expect the compiler/VM to notice the case and...

Is code clearness killing application performance?

As today's code is getting more complex by the minute, code needs to be designed to be maintainable - meaning easy to read, and easy to understand. That being said, I can't help but remember the programs that ran a couple of years ago such as Winamp or some games in which you needed a high performance program because your 486 100 Mhz wo...

How to create an optimized packaging function in python?

So I have been given the task to create a shipping module for a webshop system. It may be a bit overkill, but I would really like to create one that can figure out how to pack parcels in the most optimized way. Having learned programming simply by doing it, this is an area where I have no knowledge - yet! Anyways I can just give short de...

MySQL Performance: Single table or multiple tables

Hiya, I have a 8 sets of data of about 30,000 rows for each set, the data is the same structure just for different languages. The front end of the site will get relatively high traffic. So my question is regarding MySQL performance, if i should have a single table with one column to distinguish which set the data belongs to (i.e. colo...

What's more efficient: a Timer, an EnterFrame event or a basic tween with extra code?

Greetings. I'm building a video player in ActionScript 3, that's supposed to be targeted on performance. It has to play large h264 videos via RTMP, with the least possible processor load. There's not much control on the actual video playback part, but my approach is to try and not kill the processor with the chrome and other additional ...

An unbounded set of hashes based on bounded sets of hashes based on paths

Suppose there is a tree, for argument's sake an XML tree. And you want a complete set of root to node paths, however you want to divide that set into groups of i, where i is user specified. So for example a html document: /html /html/head /html/head/title /html/head/title/[text] /html/body /html/body/[text] becomes for example...

Java compiler handles inline Strings efficiently?

1. static final String memFriendly = "Efficiently stored String"; System.out.println(memFriendly); 2. System.out.println("Efficiently stored String"); Will Java compiler treat both (1 and 2) of these in the same manner? FYI: By efficiently I am referring to runtime memory utilization as well as code execution time. e.g. can the 1s...

passing a string by reference to a function would speed things up? (php)

Possible Duplicate: In PHP (>= 5.0), is passing by reference faster? I wonder if by declaring the parameter pass by reference, the PHP interpreter will be faster for not having to copy the string to the function's local scope? The script turns XML files into CSVs, which have thousands of records, so little time optimizations cou...

Optimal C Structure definition

Hi, I was just wondering about the considerations to be followed while packing items (int, float, unions, etc) in a C structure (C struct definition ) that would allow the compiler to further optimize it. I would like to know whether there are any guidelines that one should follow e.g. adding items to the structure in an order that wo...

Django (?) really slow with large datasets after doing some python profiling

Hi, I was comparing an old PHP script of mine versus the newer, fancier Django version and the PHP one, with full spitting out of HTML and all was functioning faster. MUCH faster to the point that something has to be wrong on the Django one. First, some context: I have a page that spits out reports of sales data. The data can be filter...

In C, which is faster: if with returns, or else if with returns?

Is it better to have if / else if, if every block in the if statement returns, or is it better to have a chain of ifs? To be specific, which if fastest: A: if (condition1) { code1; return a; } if (condition2) { code2; return b; } //etc... B: if (condition1) { code1; return a; } else if (condition2) { code2; return b;...

How do I improve the performance of code using DateTime.ToString?

In my binary to text decoding application (.NET 2.0) I found that the line: logEntryTime.ToString("dd.MM.yy HH:mm:ss:fff") takes 33% of total processing time. Does anyone have any ideas on how to make it faster? EDIT: This app is used to process some binary logs and it currently takes 15 hours to run. So 1/3 of this will be 5 hours. ...

Smart ASCII string representation

I have an app that converts binary file into ASCII file. With profiler I found that I spend 25% of time doing Encoding.GetBytes() which is called from BinaryWriter.Write(wchar[]). It is completely correct since I have many constructs similar to this one: m_writer.Write("some fancy long text".ToCharArray()); Do you have any smart idea...

Refactoring animations in jQuery login script

I'm using jQuery to build simple animations for a login form in my CMS. The jQuery toggles the visibility of two forms, a login form, and a reset password form. The script works perfectly fine, but I seem to figure out how to shorten it up, since most of the code is redundant. Note: The .click function is called twice in each case to ...