I was browsing Google Code when I chanced upon this project called JSpeed - optimization for Javascript.
I noticed one of the optimization was to change i++ to ++i in for loop statements.
Before Optimization
for (i=0;i<1;i++) {}
for (var i = 0, j = 0; i < 1000000; i++, j++) {
if (i == 4) {
var tmp = i / 2;
}
if (...
Hi,
Is there any way I can use JavaScript (or jquery) to stop loading unwanted objects on a webpage if i'm not interested in them. I use greasemonkey firefox addon to use bits of javascript for my better web experience and some sites use excessive flash and image content that is irrelevant to me. I'm able to hide their display using jque...
First,
the set up:
I have a script that executes several tasks after a user hits the "upload" button that sends the script the data it need. Now, this part is currently mandatory, we don't have the option at this point to cut out the upload and draw from a live source.
This section intentionally long-winded to make a point. Skip ahea...
Hi
I am trying to do problem 254 in project euler and arrived at this set of functions and refactor in Haskell:
f n = sum $ map fac (decToList n)
sf n = sum $ decToList (f n)
g i = head [ n | n <- [1..], sf n == i]
sg i = sum $ decToList (g i)
answer = sum [ sg i | i <- [1 .. 150] ]
Where:
f (n) finds the sum of the factorials ...
I have a web application written in PHP. It uses MySQL for data storage. Today I decided to profile it to find bottlenecks in code and find which parts of it are running slower that the others. The usual stuff. I did a lot of work and now my page loads in less than 0.05 seconds on my desktop.
But now my profiler tells me that half of th...
Which of the following pieces of code is more expensive?
x = my_array.inject {|sum,i| int+=i }
or
x = eval(my_array.join('+'))
...
I'd like to have a better understanding of what optimizations HotSpot might generate for my Java code at run time.
Is there a way to see the optimized code that HotSpot is using after it's been running for a while?
...
If I have an object with 50 getters/setters, where every 10 of them is defined under a new interface, and I type the object as one of those interfaces, will it increase performance?
Not sure how method/variable lookups work, but it seems that if you type the object to something that has fewer methods, it would be faster to run those met...
What is the cost of using Arrays.asList to convert static object arrays? Assuming that the object array has N items is it just an O(N) algorithm, where all of the items are copied by reference or is it merely a facade where the original array is put behind a List facade?
...
I have a database with questions and answers that get translated into all languages that site is used by. But when a question is not translated yet I want to show that question in english language. So a gettext-like behavior.
My current SQL query for this looks like this:
SELECT * FROM questions_view WHERE `language` = "de" AND `#paren...
Let's say I have entities A, B, C and each A has many B and C entities. I want to query a load of A entities based on some criterea, and I know I will be accessing all B and C entities for each A I return.
Something like select a from A as a join fetch a.b join fetch a.c would seem to make sense at first, but this creates a huge product...
I'm attempting to wrap a user-inputted string in double quotes for output but I want to make sure I don't end up with double double quotes on either side of the string. For example, if a user posts
"Hello"
I don't want to turn it into
""Hello""
I can do this fairly easily using the code below, however I'm concerned that this...
I am working with a legacy database schema that looks like this:
product_table table has fields:
uid (int, primary key)
name (varchar 50)
category table has fields:
uid (int, primary key)
name (varchar 50)
Allright, now the product_table has 4 MM relations to the category table:
product_table__category_1__mm has fields:
uid_l...
Hello,
Me and my friend are trying to accelerate a 2D game with OpenGL. The video chipset is Radeon X1250 which seems to be underpowered and can display up to some 80 1366x768 full frames/s. Given that we are drawing many sprites on top of each other the performace drops dramatically under the 60 FPS we are targeting at. Could you pleas...
Are there any tips / best practices / secrets for optimizing the size of AS3 SWF files? In particular, any way to get a breakdown of what is taking up space inside the SWF, like you used to be able to in the old Flash 7/8 days? I'm not using the Flash IDE any more, but now I'm using either Flex Builder or FlashDevelop, so it needs to be ...
We run a number of web applications written in PHP. Unfortunately there are some select queries within these with some pretty hefty joins which are causing MySQL to become less responsive.
Because of this we are looking into caching some of the regularly used joins. I have looked into Zend_Cache which looks promising, are there any oth...
I am looking for algorithm to solve the following problem :
I have two sets of vectors, and I want to find the matrix that best approximate the transformation from the input vectors to the output vectors.
vectors are 3x1, so matrix is 3x3.
This is the general problem. My particular problem is I have a set of RGB colors, and another se...
Goal: Suggest objects based on user's choices
Data: Table containing info on how users would order a subset of objects from the worst to the best; Example:
1 2 3 4 5 6
John: A B G J S O
Mary: A C G L
Joan: B C L J K
Stan: G J C L
There's about 20 times as many users as objects, every user's lineup contains 5...
Is there an advantages to putting all my small widget graphics in one single png-file, which is loaded once, and then creating ImageIcons for buttons and such from sections of this?
(Normally I would just use new ImageIcon(aClass.class.getResource("/path/with/image.png")).)
What would be a good way of doing this?
...
A colleague and I are going back and forth on this issue and I'm hoping to get some outside opinions as to whether or not my proposed solution is a good idea.
First, a disclaimer: I realize that the notion of "optimizing DateTime.Now" sounds crazy to some of you. I have a couple of pre-emptive defenses:
I sometimes suspect that those ...