efficiency

Which is more efficient when initializing a primitive type?

When declaring primitives does it matter if I use the assignment operator or copy constructor? Which one gives the optimal performance, or do most compilers today compile these two statements to the same machine code? int i = 1; int j( 1 ); ...

Efficient way to save data to disk while running a computationally intensive task

Hi, I'm working on a piece of scientific software that is very cpu-intensive (its proc bound), but it needs to write data to disk fairly often (i/o bound). I'm adding parallelization to this (OpenMP) and I'm wondering what the best way to address the write-to-disk needs. There's no reason the simulation should wait on the HDD (which is...

Should I use a string table to make database more efficient?

Let's say you have a database with a single table like... --------------------------------------------- | Name | FavoriteFood | --------------------------------------------- | Alice | Pizza | | Mark | Sushi | | Jack | Pizza | ----...

Do any laser keyboards allow you to move around keys to your liking?

The lack of uniformity of the pgup print screen arrows etc is getting on my nerves. I am wondering if any of the laser keyboards would make me a more efficient keyboarder by allowing me to adjust those keys and make fewer mistakes in programs, emails, and administrative tasks. ...

Most Efficient MySQL query to update a table from identical memory table

I'm implementing a memory cache for a table that looks like this (simplified): Item1 (integer), Item2 (integer), cnt (Integer) The original table includes millions of pairs like this. and it updates rapidly. To make it all more efficient I want to write new pairs to an identical memory table and update the real table on disk periodica...

Writing Clean and Efficient PHP Code

I have been looking around online and I cant seem to find an article on this that isn't totally outdated. Does anyone have any good articles that give some good advice? What I have read so far is good, and a bit helpful, but I want to have modern code examples, not ones from 2002. I have coded an extensive PHP/MySQL program and I am tr...

Lots of small files or a couple huge ones?

In terms of performance and efficiency, is it better to use lots of small files (by lots I mean as much as a few million) or a couple (ten or so) huge (several gigabyte) files? Let's just say I'm building a database (not entirely true, but all that matters is that it's going to be accessed a LOT). I'm mainly concerned with read performa...

How to tag texts automatically while remaining effectivness?

Let's say I've got a set of a million tags and a text that needs to be parsed for these and possibly new tags. The amount of tags here is just an example to illustrate my thinking problem - too many to loop through in a linear way, too many to keep in memory etc. Somehow I can't think of a solution with low footprint (and which stays sp...

PHP function efficiencies

Hi, Is there a table of how much "work" it takes to execute a given function in PHP? I'm not a compsci major, so I don't have maybe the formal background to know that "oh yeah, strings take longer to work with than integers" or anything like that. Are all steps/lines in a program created equal? I just don't even know where to start rese...

Which block of code is 'better'?

In order to promote good programming habits and increase the efficiency of my code (Read: "My brother and I are arguing over some code"), I propose this question to experienced programmers: Which block of code is "better"? For those who can't be bothered to read the code, is it worth putting a conditional within a for-loop to decrease t...

How to normalize a vector in MATLAB efficiently? Any related built-in function ?

I normalize a vector V in MATLAB as following: normalized_V = V/norm(V); however, is it the most elegant (efficient) way to normalize a vector in MATLAB? ...

How to solve a while true loop as it is expensive and Risky

Hello all, I make an AJAX request to see if a sesion variable has been set. I make a GET request to this script: <?php session_start(); while(true){ if(isset($_SESSION['screen_name'])){ return true; break; } } ?> Clearly there are problems with this script and I wanted to solve these problems such as the continuou...

Efficiently get unretrieved message Ids from a POP3 server.

I understand most of the POP3 protocol, but one thing that bothers me is how POP3 clients efficiently get a list of unretrieved message ids from the POP3 server. Many services like Yahoo and Gmail now offer gigs of space and most people (myself included), rarely if ever delete an email message. I'm currently implementing a simple POP3 c...

C++ STD::Vector using templated function taking abnormally long to run

The following function operates with two values for T. One is 4 bytes (same as a DWORD). The other is 64 bytes. The Buffer is designed to store objects in its cache, and have them retrieved at a later date. When using the 64 byte structure, the total amount of time in the function jumps dramatically. The seek time in the vector, the...

Is this a good way to use dlls? (C++?)

I have a system that runs like this: main.exe runs sub.exe runs sub2.exe and etc. and etc... Well, would it be any faster of more efficient to change sub and sub2 to dlls? And if it would, could someone point me in the right direction for making them dlls without changing a lot of the code? ...

Linked List: Is this solution good?

I was looking for a way to avoid starting from the head of the list each time I want to find a node, so I thought of assigning indexes to nodes, keeping a pointer to a random (not exactly random; see below) node and then finding the pointer that's closest to the index I want to find. Allow me to explain with code: // head and last are p...

Which is more Efficient? More Cores or More CPUs

I realize this is more of a hardware question, but this is also very relevant to software, especially when programming for mult-threaded multi-core/cpu environments. Which is better, and why? Whether it be regarding efficiency, speed, productivity, usability, etc. 1.) A computer/server with 4 quad-core CPUs? or 2.) A computer/server...

Efficient algorithm for Next button on a MySQL result set

I have a website that lets people view rows in a table (each row is a picture). There are more than 100,000 rows. You can view different subsets of the rows, and you can view them with different sort orders. While you are viewing one of the rows, you can click the "Next" or "Previous" buttons to go the next/previous row in the list. ...

Is Google App Engine good for scalablity and portability?

I'm evaluating hosted production environments and currently have interest in Google App Engine. Currently I'm enjoying the free quotas. I'm concerned if it is efficient to scale up using Google App Engine. Portability is being analyzed as well. Please advise if Google App Engine is good for scalability and portability. Thank you in ...

DrawDib StretchDIBits which one is faster?

I've never used DrawDib APIs, My Application's UI rendering is based on stretchDIBits. Because there are really lots of large images to draw , the stretchDIBits's (HAFTONE is used to get better render result) performace is bad... I heard about DrawDib is a group of efficient APIs to draw DIBs to DC. Is it better than stretchDIBits? Ca...