optimization

JavaScript - Are loops really faster in reverse...?

I've heard this quite a few times. Are JavaScript loops really faster when counting backward? If so, why? I've seen a few test suite examples showing that reversed loops are quicker, but I cant find any explanation as to why! I'm assuming it's because the loop no longer has to evaluate a property each time it checks to see if it's finis...

-fno-omit-frame-pointer without optimization

Hi, I was wondering what -fno-omit-frame-pointer will do without optimization? CXXFLAGS = -Wall -ggdb3 -DDEBUG -fno-omit-frame-pointer Isn't it that fomit-frame-pointer auto turned on at all levels of -O (except -O0)? I assume in my example it is -O0 by default. Thanks and regards! ...

Query Optimization

I have 2 queries. First: SELECT * FROM `table` WHERE col='xyz' LIMIT 100 //Time Taken: 0.0047s Second: SELECT * FROM `table` WHERE col='xyz' ORDER BY Id DESC LIMIT 100 //Time Taken: 1.8208s The second takes a much longer time. I know why that is, it is because first I have to select the whole table, then do the ordering, whereas ...

optimization and debugging options in Makefile

I wonder where to put the optimization and debugging options in Makefile: linking stage or compiling stage? I am reading a Makefile: ifeq ($(STATIC),yes) LDFLAGS=-static -lm -ljpeg -lpng -lz else LDFLAGS=-lm -ljpeg -lpng endif ifeq ($(DEBUG),yes) OPTIMIZE_FLAG = -ggdb3 -DDEBUG else OPTIMIZE_FLAG = -ggdb3 -O3 endif ifeq ($(PROF...

Optimizing my dynamic background engine for a 2d flash game in actionscript-3.

Edit 2: judging on the lack of replies I start wondering if my issue is clear enough. Please tell me if I need to elaborate more. Notice: see bottom for a code update! Short introduction: I'm writing a 2 dimensional flash space game in actionscript. The universe is infinitely big, because of this feature, the background has to be rende...

High-level/semantic optimization

I'm writing a compiler, and I'm looking for resources on optimization. I'm compiling to machine code, so anything at runtime is out of the question. What I've been looking for lately is less code optimization and more semantic/high-level optimization. For example: free(malloc(400)); // should be completely optimized away Even if thes...

C++ stack and scope

I tried this code on Visual C++ 2008 and it shows that A and B don't have the same address. int main() { { int A; printf("%p\n", &A); } int B; printf("%p\n", &B); } But since A doesn't exist anymore when B gets defined, it seems to me that the same stack location could be reused... I don't understand why th...

Reducing memory usage of .NET applications?

I was wondering if anyone had any tips to reduce the memory usage of .NET applications. Consider the following simple C# program: class Program { static void Main(string[] args) { Console.ReadLine(); } } Compiled in release mode for x64 and running outside visual studio, the task manager reports the following: Wor...

Java Preprocessor

If I have a boolean field like: private static final boolean DEBUG = false; and within my code I have statements like: if(DEBUG) System.err.println("err1"); does the Java preprocessor just get rid of the if statement and the unreachable code? ...

C : gdb behavior : value optimized out

Can anyone explain this behavior of gdb :- 900 memset(&new_ckpt_info,'\0',sizeof(CKPT_INFO)); (gdb) **903 prev_offset = cp_node->offset;** (gdb) **905 m_CPND_CKPTINFO_READ(ckpt_info,(char *)cb->shm_addr.ckpt_addr+sizeof(CKPT_** HDR),i_offset); (gdb) **903 prev_offset = cp_node->offset;** (gdb) **905 ...

GROUP BY Optimization [MySQL]

Hey. I´ve got these two tables in a 1:n relation. CREATE TABLE IF NOT EXISTS `de_locations` ( `id` int(11) NOT NULL auto_increment, `user_id` int(11) default NULL, `author_id` int(11) NOT NULL, `city_id` int(11) NOT NULL, `district_id` int(11) NOT NULL, `title` varchar(150) collate utf8_unicode_ci NOT NULL, `description` tinytext collat...

How do you measure site load time in IE6?

I'm looking for something similar to Hammerhead. Currently, I write javascript code to test, and I'd rather just use a tool that I can easily share and has a GUI. Edit: I'm hoping for something that tracks load events if possible and can easily do repeat tests. ...

Query Optimization - Why does this speed up the Query?

I'm using Quest's TOAD for SQL Server on a SQL Server 2000 Server. Here is my query: SELECT CASE SLCE.GroupName WHEN 'Other' THEN ARM.FBCOMPANY WHEN 'Inter Co.' THEN ARM.FBCOMPANY ELSE SLCE.GroupName END AS [Company Name], ARM.fcustno AS [Cust No], ARM.fbcompany ...

Boolean expressions optimizations in Java

Consider the following method in Java: public static boolean expensiveComputation() { for (int i = 0; i < Integer.MAX_VALUE; ++i); return false; } And the following main method: public static void main(String[] args) { boolean b = false; if (expensiveComputation() && b) { } } Logical conjunction (same as &&) is a commutative o...

How big is the speed difference between XPathNavigator and XmlReader, really?

I've got a fairly big XML file that I need to parse into a .NET class structure (to be mapped to a fixed-length record format and transmitted via MQ). Performance is important, but not absolutely critical. I almost always use XPathNavigator to read XML files because it's much easier than XmlReader. On the other hand, I know XmlReader i...

How can I code Java to allow SSE use and bounds-check elimination (or other advanced optimizations)?

The Situation: I'm optimizing a pure-java implementation of the LZF compression algorithm, which involves a lot of byte[] access and basic int mathematics for hashing and comparison. Performance really matters, because the goal of the compression is to reduce I/O requirements. I am not posting code because it isn't cleaned up yet, and...

Filtering jQuery Results by CSS Tag

I am trying to dynamically filter search results. Every result has tags associated with it that are used as classes. <div class="search_results"> <div class="html php jquery"> I can do HTML, PHP and JQuery. </div> <div class="jquery asp pascal"> I can do jQuery, ASP, and Pascal. </div> <div class="php bas...

How to simplify/optimize a 3d path ?

I have a bunch of points in 3d ( an array that contains objects with x,y,z properties ). My problem is that there are a lot of unnecessary points as illustrated in the image bellow: How can I cleanup this path ? At the moment the first thing that comes to mind is to create an array for the optimized path loop though all the poin...

Time complexity of the program

#include<stdio.h> #include<time.h> int main() { clock_t start; double d; long int n,i,j; scanf("%ld",&n); n=100000; j=2; start=clock(); printf("\n%ld",j); for(j=3;j<=n;j+=2) { for(i=3;i*i<=j;i+=2) if(j%i==0) break; if(i*i>j) prin...

SQL Server is extremely slow when running queries on the Stack Overflow data dump

I imported the Stack Overflow data dump into SQL Server 2008. Some queries, especially on the Posts table, are taking more than a minute to return. Example query: SELECT Id, PostTypeId, AcceptedAnswerId, CreationDate, Score, ViewCount, Body, OwnerUserId, OwnerDisplayName, LastEditorUserId, LastEditDate, LastActivityDate, Tit...