optimization

How to store static content across branches in a single location in version control

[Just a random thought] I have a pdf doc that is downloaded when the user clicks on 'help' on my website. Now, this is a pretty huge document and is saved in version control (SVN) and is thus copied for all branches that exist in SVN. This is static content and something that developers are not working on, and does not change often. Is ...

Wrapping element in choose construction. How to improve?

Is there any way to optimize this code. <xsl:choose> <xsl:when test="val1 = val2"> <xsl:apply-templates select="node"/> </xsl:when> <xsl:otherwise> <div> <xsl:apply-templates select="node"/> </div> </xsl:otherwise> </xsl:choose> I do not like having to write twice the same <xsl:appl...

Optimize code performance when odd/even threads are doing different things in CUDA

I have two large vectors, I am trying to do some sort of element multiplication, where an even-numbered element in the first vector is multiplied by the next odd-numbered element in the second vector... and where the odd-numbered element in the first vector is multiplied by the preceding even-numbered element in the second vector. For e...

Is it worth it to apply a cdn to static media on a production site?

Pretty much all of our sites are setup the standard mod_php, apache2, LAMP style with the static media living on the same domain as the dynamic php scripts. I'm wondering if there are any practical benefits to actually switching to a cdn? If I'm not really having issues with my server performance, is it really worth it? ( Our servers ty...

Hierarchical Hibernate, how many queries are executed?

So I've been dealing with a home brew DB framework that has some seriously flaws, the justification for use being that not using an ORM will save on the number of queries executed. If I'm selecting all possibile records from the top level of a joinable object hierarchy, how many separate calls to the DB will be made when using an ORM (...

Sparkline rendering is slow and hangs browser

Sparklines are awesome for doing little inline graphs. However, if the container they are in is hidden, you can't simply draw them behind the scenes and then show them. You must first display the container and then call the $.sparkline_display_visible method. This is ok, except that it's really slow if you have a lot of graphs. I have a...

Initializing a C++ vector to random values... fast

Hey, id like to make this as fast as possible because it gets called A LOT in a program i'm writing, so is there any faster way to initialize a C++ vector to random values than: double range;//set to the range of a particular function i want to evaluate. std::vector<double> x(30, 0.0); for (int i=0;i<x.size();i++) { x.at(i) = (rand(...

Postgre database ignoring created index ?!

I have an Postgre database and a table called my_table. There are 4 columns in that table (id, column1, column2, column3). The id column is primary key, there are no other constrains or indexes on columns. The table has about 200000 rows. I want to print out all rows which has value of column column2 equal(case insensitive) to 'value12'...

PostgreSQL - Why are some queries on large datasets so incredibly slow

Hello, I have two types of queries I run often on two large datasets. They run much slower than I would expect them to. The first type is a sequential scan updating all records: Update rcra_sites Set street = regexp_replace(street,'/','','i') rcra_sites has 700,000 records. It takes 22 minutes from pgAdmin! I wrote a vb.net function...

Java Compiler: Optimization of "cascaded" ifs and best practices?

Hello, Does the Java Compiler optimize a statement like this if (a == true) { if (b == true) { if (c == true) { if(d == true) { //code to process stands here } } } } to if (a == true && b==true && c==true && d == true) So that's my first question: Do both take exactly the same "CPU Cycles" or is the first varia...

Specific template for the first element.

I have a template: <xsl:template match="paragraph"> ... </xsl:template> I call it: <xsl:apply-templates select="paragraph"/> For the first element I need to do: <xsl:template match="paragraph[1]"> ... <xsl:apply-templates select="."/><!-- I understand that this does not work --> ... </xsl:template> How to call <x...

Common optimization rules

This is a dangerous question, so let me try to phrase it correctly. Premature optimization is the root of all evil, but if you know you need it, there is a basic set of rules that should be considered. This set is what I'm wondering about. For instance, imagine you got a list of a few thousand items. How do you look up an item with a sp...

What's the steps for SQL optimization and changes without reflect live system ?

we have a big portal that build using SharePoint 2007 , asp.net 3.5 , SQL Server 2005 .. many developers work in it since 01/2008 and we are now doing huge analysis for current SQL Databases [not share-point DB ] to optimize and enhance it. The main db have about 330 table and 1720 stored procedure (SP) created from 01/2008 till now Ma...

SSIS - Connection Management Within a Loop

Hi I have the following SSIS package: The problem is that within the Foreach loop a connection is opened and closed for each iteration. On running SQL Profiler I see a series of: Audit Login RPC:Completed Audit Logout The duration for the login and the RPC that actually does the work is minimal. However, the duration for the lo...

Any Javascript optimization benchmarks?

I watched Nicholas Zakas' talk, Speed up your Javascript, with some interest. I liked how he benchmarked the various performance improvements created by various optimization techniques, e.g. reducing calls to deeply nested objects, changing loops to count down instead of up, etc. I would like to run these benchmarks myself though, to se...

Optimising a query for Top 5% of users

On my website, there exists a group of 'power users' who are fantastic and adding lots of content on to my site. However, their prolific activities has led to their profile pages slowing down a lot. For 95% of the other users, the SPROC that is returning the data is very quick. It's only for these group of power users, the very same SP...

Optimizing Vector elements swaps using CUDA

Hi all, Since I am new to cuda .. I need your kind help I have this long vector, for each group of 24 elements, I need to do the following: for the first 12 elements, the even numbered elements are multiplied by -1, for the second 12 elements, the odd numbered elements are multiplied by -1 then the following swap takes place: Graph: b...

Expire headers in Rails

Hi, I started using YSlow and I noticed that I haven`t got expire headers on my static files. So I did a little research what is that and how to add it and tried to turn it on from the .htaccess file. But the problem is that when I put the code in the file apache returns me a 500 error. And I started thinking that the problem is from Rai...

Fast read of certain bytes of multiple files in C/C++

I've been searching in the web about this question and although there are many similar questions about read/write in C/C++, I haven't found about this specific task. I want to be able to read from multiple files (256x256 files) only sizeof(double) bytes located in a certain position of each file. Right now my solution is, for each file:...

Optimizing near-duplicate value search

I'm trying to find near duplicate values in a set of fields in order to allow an administrator to clean them up. There are two criteria that I am matching on One string is wholly contained within the other, and is at least 1/4 of its length The strings have an edit distance less than 5% of the total length of the two strings The Pse...