optimization

Optimizing Java code

How can I optimize this code ? I made IPFilter and I need to optimize it. package com.ipfilter; import java.util.HashMap; import java.util.Map; /** * IPFilter * * Loads given IP addresses to memory, so you can easily check if ip addres has been blocked */ public class IPFilter { private Map<Integer, IPFilter> ...

WPF optimization: logical trees in xaml, how are they being built?

I've been profiling my application and finding that a lot of the delays are due to the WPF initializations. I've found an article on WPF optimization saying that building a logical tree top-down will have better performance than if it were built bottom-up. The example in the article is in C#. I'm wondering, when the UI is done in XAML, h...

Can this function be made faster? Javascript

I have a function that gets an array of DOM elements (based on tags) within a div. Pseudocode: 1. Say I wanted to get all input and textarea elements within a table myTbl 2. Declare resultingArray = null 3. For each tag (ex: input, textarea) 4. tagArray = Get all elements based on tag 5. Create another array by manually looping thro...

Intel x86 assembly optimization techniques in a sample problem.

I am learning assembler quite a while and I am trying to rewrite some simple procedures \ functions to it to see performance benefits (if any). My main development tool is Delphi 2007 and first examples will be in that language but they can be easily translated to other languages as well. The problem states as: We have given an unsigne...

Postgres Convert String to Number

I have a multi-million row table with a varchar field. Some of the rows of the varchar are floating point numbers. There is no constraint on other fields that can completely isolate which rows are numbers and which are not. I want to create queries with an ORDER BY on the rows with the numeric value in the varchar field (ignoring non-...

How to find rows in one table that have no corresponding row in another table

I have a 1:1 relationship between two tables. I want to find all the rows in table A that don't have a corresponding row in table B. I use this query: SELECT id FROM tableA WHERE id NOT IN (SELECT id FROM tableB) ORDER BY id desc id is the primary key in both tables. Apart from primary key indices, I also ha...

Is there an advantage to using very specific selectors in CSS?

I understand that in jQuery, it's advantageous to be more specific when using selectors so that jQuery doesn't have to traverse the entire DOM to find what you're looking for. For example, $('span.description') is better than just $('.description') if I know that the description class is only ever applied to <span> elements. Is this the...

does C++ automatically cast const ints to floats?

I am aware that casting ints to floats (and vice versa) is fairly expensive. However, does the compiler automatically do it at compile time for constants in your code? For e.g. is there any difference between float y = 123; float x = 1 / y; and float y = 123.f; float x = 1.f / y; I see some code that does the latter, but I'm not su...

Optimizing the build performance of an ASP.NET web site project?

I'm currently working with an ASP.NET CMS that keeps close to 500 code files in the App_Code directory, as well as hundreds of web forms with code-behind in various folders of the site. It is a web site project (not a web application project) and I'm reluctant to change it since this is a project with multiple developers involved, plus t...

Compress a Mysqldump that is SSH'd to another machine

I have the following: mysqldump -u xxxx -h localhost --password=xxxxx databasename | ssh [email protected] "dd of=httpdocs/backup`date +'%Y-%m-%d-%H-%M-%S'`.sql" ...which SSH's a mysqldump to a remote machine. I need to compress the mysqldump before it is SSH'd as the dump is 500mb and its e...

Is there an iterative way to calculate radii along a scanline?

I am processing a series of points which all have the same Y value, but different X values. I go through the points by incrementing X by one. For example, I might have Y = 50 and X is the integers from -30 to 30. Part of my algorithm involves finding the distance to the origin from each point and then doing further processing. After ...

Did you try Doloto "AJAX application optimization tool" ? have any comments/concerns about?

MSDN launched Doloto, Doloto is an AJAX application optimization tool, especially useful for large and complex Web 2.0 applications that contain a lot of code. Anyone tried it till now, have any comments/concerns about? ...

Search through a big list fast with jQuery

I'm using this code to search trough about 500 li tags. $(function() { $.expr[":"].containsInCaseSensitive = function(el, i, m){ var search = m[3]; if (!search) return false; return eval("/" + search + "/i").test($(el).text()); }; $('#query').focus().keyup(function(e){ if(this.value.length > 0){ $('ul#abbreviations li'...

Array access optimization

Hi all, Just a quick question really. Say I have a 10x10 array in Java, some of the places in which are not used, and I'm needing to go through all elements as part of a method. Would it be better to: Go through all elements with 2 for loops and check for the nulltype to avoid errors, e.g. for(int y=0;y<10;y++){ for(int x=0;x<10;x...

what is the best way to multiply arrays in php?

Hello lets say I have two arrays <?PHP $arr1 = array("a","b","c"); $arr2 = array("1","2","3"); function multiply_arrays($arr1,$arr2){ //what is the best way to do that in terms of speed and memory return $arr3; } ?> what is the best way to multiply them? the result should ...

F#: Partial application and precalculation

Looking at a function in my code today, I wondered if it was possible to combine partial combination and optimisation: let foo (X:float) y1 y2 dx = y1 + (y2 - y1) * dx / X Basically, just applying a ratio - so the first three parameters are generally the same within a given loop. I thought maybe if I just did this: let foo2 (X:...

Optimizing : constructing a jquery collection

I have this Jquery code that construct a collection of jquery objects. It takes around 600 ms to execute. I want to optimize it: var tousBt = $('img.boutonReduire'); var stack = $(''); tousBt.each( function() { var id = $(this).attr('id'); stack = stack.add('#table' + id).add('#img' + id); }); Do you see something that I can...

Select * from table OR select id,field1, field2, field3 from table - best practice?

Could someone chime in as to whats a better practice? for select queries should I return all or the IDs that I require? Efficiency? Scalability? etc. thanks Env: SQL Server 2008, VS2008 (VB) ...

What is the best way to store and search through class objects (in PHP)?

I've around 80 instances of this class called Items and would like to efficiently search the objects by their ID or NAME. <?php class Item { public $id; public $name; //methods } ?> I'm using PHP5. ...

how to speed up Mysql and PHP?

Hello I am developing a script in my localhst using PHP and mysql and I am dealing with large data (about 2 millions of records for scintific research) some queries I need to call once in a life (to analyse the data and prepare some data); however it takes very long time for example: now my script is analysing some data for more than 4...