speed

PHP include(): File size & performance

An inexperienced PHP question: I've got a PHP script file that I need to include on different pages lots of times in lots of places. I have the option of either breaking the included file down into several smaller files and include these on a as-needed basis... OR ... I could just keep it all together in a single PHP file. I'm wonderi...

Are any of these quad-tree libraries any good?

It appears that a certain project of mine will require the use of quad-trees, something that I have never worked with before. From what I have read they should allow substantial performance enhancements than a brute-force attempt at the problem would yield. Are any of these python modules any good? Quadtree 0.1.2 <= No: unable to execu...

VB6 IP4 - Calculate Net Mask (Long) from Number of Bits

Given input of 0 to 32, representing the number of one-bits in an IP4 network mask (corresponding to a CIDR block size as in /19), what's An elegant way to turn that into a four-byte long net mask A fast way way to turn that into a four-byte long net mask Prototype: Function NetMaskFromBitCount(BitCount As Long) As Long 'Logic he...

Limit Speed Of Gameplay On Different Computers

I'm creating a 2D game using OpenGL and C++. I want it so that the game runs at the same speed on different computers, At the moment my game runs faster on my desktop than my laptop (i.e. my player moves faster on my desktop) I was told about QueryPerformanceCounter() but I don't know how to use this. how do I use that or is there a b...

Implementing parallel static content download in the browser?

We are looking at adjusting our web pages so we split our calls for static data across sub-domains. In order to do this we must: Always serve the same content from the same sub-domain so it remains cached Try and serve roughly the same amount of content from each of the sub-domains Try to do this in an automatic way on a per-page basis...

AI Chess Valid Moves

Hello everybody! I am trying to write AI Chess and I have a problem. I am ready with pieces movement rules, and I'm trying to remove moves that are not valid (leave the king in check etc). I Wrote something like this: ValidateMove(board); { for(i=0;i<64;i++) if(board[i]==king.opposite) kingpos=board[i]; createmoves(board); if (moves.c...

What situations demand the use of eval() because there are no alternatives?

I know eval should be avoided in JavaScript for speed and security reasons. But in the case of PHP, rarely is security ever mentioned. More often, it's your program running slower than it should because of a haphazard use of eval. In what specific situations should you use eval because there is no other way around it? For clarity: We'...

Parse/regex one field after query using PHP or store segmented data in multiple fields?

Should I plan to parse/regex, for example, an entire url string retrieved from one field of a database table during a while loop of query results using PHP? Or should I store segments of the data (directory, filename, extension) in their own separate fields and concatenate the results during a while loop of query results? Assuming wo...

Using SELECT with a primary key in MySQL

I'm trying to speed up my SELECT queries in my web application. I have done some pretty major optimizations, like ordering the rows returned by PHP rather than MySQL itself. Now I'm just wondering, is it faster to use the SELECT statement on columns that are a primary key? Example, I have a table set up with the columns settingKey and s...

How fast is VB .net compared to native code for arithmetic?

I need to write software that will do a lot of math. Mostly it will be matrix multiplication with integers to compute DCT. How much faster should I expect the code to run in native c as compared to VB .Net? Factor of 2, factor of 10, factor of 1000...? Has someone tried and collected statistics on this? ...

Auto-suggest with quick response using PHP/KohanaPHP + MySQL + jQuery

I need to know how to execute this in the best way possible so that the suggestions will load really quick and secured. I want something like how the Related Questions work here after typing a question title. ...

PHP speed: what is faster? if (isset ($foo)) OR if ($foo==true)

Hi, just trying to optimize my code. I need to prefill a form with DB data and I need to check if the variable exist to fill the text box (I dont like the @ error hiding). The form is really long, then I need to check multiple times if the variables exist. Then what is faster: if (isset ($item)) if ($item_exists==true) or even if ...

Refactoring (and testing) for performance

I have a library that provides a reflection API on top of describeType() (a method that returns an XML object with all the specs of a class or instance). Since this library is used in several other libraries and frameworks, I really want it to be as fast as possible. The problem I'm facing is that I'm not sure about the best approach to...

Writing shorter code/algorithms, is more efficient (performance)?

After coming across the code golf trivia around the site it is obvious people try to find ways to write code and algorithms as short as the possibly can in terms of characters, lines and total size, even if that means writing something like: //Code by: job //Topic: Code Golf - Collatz Conjecture n=input() while n>1:n=(n...

speeding up website load using multiple servers/domains

When Yahoo! developer guide says "Deploying your content across multiple, geographically dispersed servers will make your pages load faster from the user's perspective". And as an explanation I read somewhere, that browsers will load up to 5 things simultaneously from the same domain. Would a subdomain, for example cdn.example.com be ...

how to get the colors on the screen better then get pixel? (c++)

i made a program that uses the colors of pixels from the screen but getpixel is slow so is there a better way to find the color of pixels. i don't care if i get the full screen or one pixel at a time but the main thing is speed. ...

Document Similarity: Comparing two documents efficiently

I have a loop that calculates the similarity between two documents. It collects all the tokens in a document and their scores, and places them in dictionary. It then compares the dictionaries This is what I have so far, it works, but is super slow: # Doc A cursor1.execute("SELECT token, tfidf_norm FROM index WHERE doc_id = %s", (docid...

Optimizing for speed - 4 dimensional array lookup in C

I have a fitness function that is scoring the values on an int array based on data that lies on a 4D array. The profiler says this function is using 80% of CPU time (it needs to be called several million times). I can't seem to optimize it further (if it's even possible). Here is the function: unsigned int lookup_array[26][26][26][26]; ...

C# Array or Dictionary?

Hi. I wanted to know is C# array has a constant access speed? I need to store 1000 items in static array, that will be initialized during server startup. This array will be used readonly, so there will be no changes to array. Should I use a simple C# array (new MyClass[]) or Dictionary instead. I am really new to C# and trying to unders...

Java - How to change Mouse-Speed in Windows

Yeah, thats the Question. How can I change the Mouse-Speed in Windows in Java? Greets ...