optimization

Detecting Memory Leaks in ActionScript-3 Project.

Hi! Is there any way to detect memory leaks in Flash ActionScript-3 project? what are the easier ways to achieve this in existing project ? ...

Implement object-caching in classic ASP memory-leaking

I have tried to implement different caching-implementations in a classic ASP site in order to offload the database during heavy traffic. My approach was this: Create a global HashTable object in global.asa where I later on store jscript-objects within <object id="SIZE_LIST" progid="System.Collections.HashTable" runat="Server" scope="A...

Why does MySQL use the wrong index?

Hello! I have another question regarding optimizing mysql indices for our prioritizing jBPM. The relevant indices look like this: | JBPM_TIMER | 1 | JBPM_TIMER_REVERSEPRIORITY__DUEDATE_ | 1 | REVERSEPRIORITY_ | A | 17 | NULL | NULL | YES | BTREE | | | JBPM_TIMER | ...

HTTP requests optimization: What is the limit?

It is common knowledge now to combine stylesheets and scripts in effort to reduce HTTP Requests. I have 2 questions: How expensive are they, really? When is a request too big it should be split? I cannot find the answers to these two questions in all online readings I did, such as Yahoo! Best Practices which states a number of times...

Is there a fast way to get the character index of a regex match?

I am creating a Perl script which will have to process the markup of millions of Wikipedia articles - so speed is an issue. One of the things I'm looking for are occurrences of templates, which always look like this: {{template}}. Because these can be complicated and nested, I need to find the start and end tags separately, and know th...

Another question about premature optimization

Knuth said: We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil I’m curious how he came up with 97%. Could someone please share something about this? UPDATE: The problem is: This sentence is written in a research paper, how come a subjective statement get accepted in such...

Actionscript 3 import package.* vs import package.Class

In Actionscript 3, is there any reel overhead between importing a full package versus importing independant classes? E.g.: import flash.display.* vs. import flash.display.Sprite I know it's a good practice to import only the needed classes from a package to avoid conflicts, but I've often been told it also has a cost in term of the com...

JS looping and populating array. Which is faster?

I just saw a video of Nicholas Zakas of Yahoo, at GoogleTalks talking about speeding up your website. One of the things he mentioned was doing loops in reverse order to skip one of two comparisons: for (i = len; i--;) {} And he said to keep away from JS libraries implementations of for each. Just for fun I thought I'd try it out. Turns ...

Optimizing Kohana-based Websites for Speed and Scalability

A site I built with Kohana was slammed with an enormous amount of traffic yesterday, causing me to take a step back and evaluate some of the design. I'm curious what are some standard techniques for optimizing Kohana-based applications? I'm interested in benchmarking as well. Do I need to setup Benchmark::start() and Benchmark::stop() f...

When is an object in Javascript constructed?

Consider the following Javascript function (1): function setData(domElement) { domElement.myDataProperty = { 'suppose': 'this', 'object': 'is', 'static': 'and', 'pretty': 'big' }; }; Now what I don't like about this function is that the exact same object is created every time the function is called. Since the objec...

Which conditional statement is faster in SQL?

SELECT a, b FROM products WHERE (a = 1 OR b = 2) or... SELECT a, b FROM products WHERE NOT (a != 1 AND b != 2) Both statements should achieve the same results. However, the second one avoids the infamously slow "OR" operand in SQL. Does that make the 2nd statement faster? ...

Is there a way to load embedded YouTube videos faster on my website?

I'm writing a blog post that uses multiple videos from YouTube and Yahoo Video, but I'm not happy with how long it takes the page to render. Apart from using an ajax-y method to load the videos, are there any tricks that would make the page load quicker with multiple videos from different sources? ...

How to find minimal amount of subdivisions

Hi, Imagine you have a canvas and in this canvas there are already some objects. How can you find the minimal way to cover the "uncovered" area with squares, not overlaying each other, completely filling the canvas. In my case the "canvas" is a html-div container and the objects are nested div-containers. Could look like this: http://...

How can I optimize this MySQL query that involves two left joins?

I cannot figure out why my query slows down. What it boils down to are four tables: team, player, equipment, and metadata. Records in player and equipment have a FK to team, making team a parent of player and equipment. And all three of those tables' rows each have a record in metadata which stores things like creation date, creator ...

Optimizing bitwise filtering in SQL

I am implementing a bitwise filter using SQL, and I want to see if the following optimization is always valid in all cases, and I'm not sure how to prove it. My goal is to limit the number of rows that get compared. Standard filter pseudo-sql: IF (A & B = A) // SHOW VALUE The question is, will it work to add this? : IF (A = B) OR (A...

Does avoiding functions increase the performance?

Here is a little test: function inc(n:integer):integer; begin n := n+1; result := n; end; procedure TForm1.Button1Click(Sender: TObject); var start,i,n:integer; begin n := 0; start := getTickCount; for i := 0 to 10000000 do begin inc(n);//calling inc function takes 73 ms //n := n+1; writing it directly takes 16 ms ...

Slow implementation and runs out of heap space (even when vm args are set to 2g)

I'm writing a function which generates all paths in a tree as xpath statements and storing them in a bag below is a naive (sorry this is long) and below that is my attempt to optimize it: /** * Create the structural fingerprint of a tree. Defined as the multiset of * all paths and their multiplicities */ protected Multiset<String> cr...

Kohana, Editing Cache doesn't Reflect in View?

I'm working on setting up caching for my site, but am having difficulty testing whether the caching is working properly or not. I've got the following in my controller: public function read($id, $slug = null) { $this->cache = Cache::instance(); $story = $this->cache->get("story".$id); if (!$story) { $story_model = new Story_M...

Linq To SQL: Why is disposing and recreating a DataContext way faster than refreshing it?

Hey, I noticed that disposing and re-creating a DataContext is way faster than refreshing it with RefreshMode.OverwriteCurrentValues, which should effectively be the same. While this causes my application to spike at 100% CPU for several seconds dbc.Refresh(RefreshMode.OverwriteCurrentValues, dbc.Property); the following code doesn...

Take screenshots **quickly** from python

A PIL.Image.grab() takes about 0.5 seconds. That's just to get data from the screen to my app, without any processing on my part. FRAPS, on the other hand, can take screenshots up to 30 FPS. Is there any way for me to do the same from a Python program? If not, how about from a C program? (I could interface it w/ the Python program, pot...