optimization

Silverlight scrolling animation utilizes large amounts of CPU time

In our app, we have some scrolling credits in a ChildWindow. When showing this window, our CPU utilization is very high. The text is using a BitmapCache and hardware acceleration is enabled. Even after removing the clipping rectangle and the drop shadow from the child window, the CPU usage climbs to 80-90%. When I enable redraw regio...

Is This a “Large” GraphViz Chart, and How to Fix it?

Hi, I started using GraphViz yesterday in order to visualize the relationships between some things—a project I’ve been wanting to tackle for quite a while now. So far, I’ve gotten it pretty well done, but there’s a few things I’m struggling with, specifically getting the chart to look good and how long it takes to process the DOT file—...

Efficient way of phrasing multiple tuple pair WHERE conditions in SQL statement

I want to perform an SQL query that is logically equivalent to the following: DELETE FROM pond_pairs WHERE ((pond1 = 12) AND (pond2 = 233)) OR ((pond1 = 12) AND (pond2 = 234)) OR ((pond1 = 12) AND (pond2 = 8)) OR ((pond1 = 13) AND (pond2 = 6547)) OR ((pond1 = 13879) AND (pond2 = 6)) I will have hundreds of thousands pond1-po...

Optimize me! (C, performance) -- followup to bit-twiddling question

Thanks to some very helpful stackOverflow users at Bit twiddling: which bit is set?, I have constructed my function (posted at the end of the question). Any suggestions -- even small suggestions -- would be appreciated. Hopefully it will make my code better, but at the least it should teach me something. :) Overview This function wil...

Is it possible to have only one comparison per iteration of a binary search algorithm?

In binary search algorithm we have two comparisons: if (key == a[mid]) then found; else if (key < a[mid]) then binary_search(a[],left,mid-1); else binary_search(a[],mid+1,right); Is there a way by which I can have only one comparison instead of the above two. -- Thanks Alok.Kr. ...

Packing, caching, JS and CSS in PHP that differentiate between development and production environment

I am trying to make development easy and have highly optimized output in production. The goals of what I am trying to do is: Make production pages fast! I would like that the Google Page Speed and YSlow return the best scores. This means: Combine and compress JS files and CSS and position the group in the right place (bottom or top o...

how much effect does number of function calls have on performance?

Does calling more functions have any kind of noticeable effect of performance, or is trying to cut down on number of function calls a pointless premature optimization? Simplified Example: Is there any real performance example between this: function foo($var) { echo $var; } foo(); And This: function foo($var) { bar($var); } f...

Best infinite loop.

Possible Duplicate: while (1) Vs. for (;;) Is there a speed difference? Hi, Which is better,faster and more optimized way to implement infinite loop - for(;;) or while(1)? and why? ...

Determine which objects in ASP.NET are used in session

I have inherited a very large ASP.NET app that needs to be modified to use a State Server instead of in-proc sessions. I need to track down all classes used in session throughout the app and then determine if they can be serialized. Are there any tools that can be used to analyze the code to determine the classes used in session? ...

Optimizing a PHP page with many queries

So i have a site that I am working on that has been touched by many developers over time and as new features arised the developers at the time felt it necessary to just add another query to get the data that is needed. Which leaves me with a php page that is slow and runs maybe 70 queries. Some of the queries are in the actual PHP file f...

What is the best optimized way to select many entities with subentities in JPA?

Let's say we have: @Entity public class Order { @Id private int id; @OneToMany(mappedBy="order") private List<Item> items; ... } and @Entity public class Item { @Id private int id; @ManyToOne private Order order; ... } And let's say there is 10.000 orders with each having 20 items. We need to iterate thought all order...

Optimizing the website with .htaccess

I've tried to optimize my website using YSlow for directions. However, even though I have added the DEFLATE code at .htaccess to gzip the files, YSlow still doesn't show the files as gzipped. I tried testing my website using this: http://www.gidnetwork.com/tools/gzip-test.php and it shows that my webpages are not gzipped or compressed. H...

Getting around the WPF rendering bottleneck

I love to make efficient apps and often look to concurrency and multithreading to improve application responsiveness and such, but lately my attempts always seem to be blocked by WPF's single-threadedness. No matter how efficient and parallel my code is, WPF seems to continually stall my UI and make my app look incredibly unresponsive--s...

Best practice for storing tags in a database?

I developed a site that uses tags (key words) in order to categorize photographs. Right now, what I have in my mysql database is a table with the following structure: image_id (int) tag (varchar(32)) Every time someone tags an image (if the tag is valid and has enough votes) it's added to the database. I think that this isn't th...

How to optimize this haskell snippet

Hi guys! I'm trying to create a small module for doing decimal-based calculations. A number is stored as an integer mantisse, with a precision value specified by an int: data APNum = { getMantisse :: Integer , getPrecision :: Int } For instance: APNum 123 0 -> 123 APNum 123 1 -> 1.23 APNum 123 2 -> 12.3 ... (negative precision...

Is Visual C++ optimizer sensitive to amount of memory available?

Turns out it is perfectly valid for a C++ compiler to emit different machine code when recompiling the same program with exactly the same compiler/environment/whatever settings. Which implies that the compiler optimizer can decide how "deep" to optimize depending on various factors, amount of available memory included. Does anyone have ...

Optimization proposals for ListView with data from multiple "tables"

Hi, I just encountered the following situation. I have an Android app with a scenario which I guess may happen in multiple apps. It's about tagging/labeling/categorizing, call it as you want. I basically have the following relations in the SQLite DB -------- -------------- --------- | Tags | ...

How do I get ID of an exiting table entry or insert a new one in case it doesn't exist efficiently?

I'm using SQLite to maintain a database which contains, among other things, a table with paths. The CREATE statement for the table looks like this CREATE TABLE path (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, UNIQUE(name)); I'm looking for a short way to say 'insert this given path into the ...

Update 20 rows in mysql with x=x+1 values?

Hi there In mysql I have a table with like 20 rows (example). I want to write sort order (it is in array that carried picID's) to the SORT column from 1 to x (x is the number of items in this example x=20). My array starts with: [10,15,1...] I can do: UPDATE table SET sort=1 WHERE picID=10 UPDATE table SET sort=2 WHERE picID=15 UPDAT...

mysql optimization with IN or OR

Dear all, I have a set of large values that need to be compared in mysql. May I know which is faster? For example: Opt 1: SELECT * FROM table WHERE v = 1 or v = 2 or v = 3 or v = 4 or... v = 100 Opt 2: SELECT * FROM table WHERE v IN (1,2,3,4,5,6,7,8,...,100) May I know which option is faster for large value? Is there any better s...