optimization

MySQL: OPTIMIZE TABLE needed on table with fixed columns?

I have a weekly script that moves data from our live database and puts it into our archive database, then deletes the data it just archived from the live database. Since it's a decent size delete (about 10% of the table gets trimmed), I figured I should be running OPTIMIZE TABLE after this delete. However, I'm reading this from the mys...

Speeding up an IO bound OpenGL application

Hi guys, I've been working on a point cloud player lately that should be ideally able to visualize terrain data points from a lidar capture and display them sequentially at around 30fps. I, however, seem to have come to a wall resulting from PCI-e IO. What I need to do for every frame is load a large point cloud stored in memory, then...

Firebird SQL: Finding bottlenecks / performance analysis

Hi, I am using Firbird 2.5 for some applications. What I miss is a performance analyses tool, e.g. for Visual Studio, which shows what methods / queries have been executed over time. I am thinking of a tool like Apple's Instruments: Is there anything like this? Thanks, Norbert ...

Loop takes forever with large count

This loop takes forever to run as the amount of items in the loop approach anything close to and over 1,000, close to like 10 minutes. This needs to run fast for amounts all the way up to like 30-40 thousand. 'Add all Loan Record Lines Dim loans As List(Of String) = lar.CreateLoanLines() Dim last As Integer = loans.Count - 1 For i = 0 T...

Looking for a mathematical solution to this small scheduling problem

Say we have a list of rooms with their capacities and a list of meetings with the number of attendees. We want to match each meeting with one room in the following way: A meeting can only be scheduled in a room with capacity equal to or greater than its attendance. If surplus rooms are present, meetings should be scheduled so that the ...

Flattening a doubly linked list with child lists - optimizations, feedback, possible modifications

Attached is a quick program written under interview conditions that is designed to flatten a doubly linked list with child links. I was wondering what folks thought and if there were some optimizations (or possibly another way of doing things) you could point out that I could learn from. Code is below - Test7 is the test of the flattenin...

This code needs to loop over 3.5 million rows, how can I make it more efficient?

I have a csv file that has 3.5 million codes in it. I should point out that this is only EVER going to be this once. The csv looks like age9tlg, rigfh34, ... Here is my code: ini_set('max_execution_time', 600); ini_set("memory_limit", "512M"); $file_handle = fopen("Weekly.csv", "r"); while (!feof($file_handle)) { $line_of_te...

How Can I Minimize Overhead when Processing Messages in a Long Loop

I've got some long but simple loops in my Delphi program that may loop millions of times and take some seconds to execute. The code inside of the loop is very fast and has been optimized. It just takes long because it is done so many times. e.g.: Screen.Cursor = crHourGlass; R := FirstRecord; while R <> nil do begin { do something si...

Improve Code: Compare 2 list of elements

Hi, sorry for the newbie question but, I'm new to programming.. I want to check if there's already no more than one element of TypeA in listOfDifferentTypes. I've following code: public void CheckType ( Object param) { if ( param is TypeA ) { int i = 0; TypeA paramToChe...

Java Profiling, Performance Tuning and Memory Profiling exercises

I am about to conduct a workshop profiling, performance tuning, memory profiling, memory leak detection etc. of java applications using JProfiler and Eclipse Tptp. I need a set of exercises that I could offer to participants where they can: Use the tool to to profile the discover the problem: bottleneck, memory leak, suboptimal code etc...

Floating point C++ compiler options | preventing a/b -> a* (1/b)

I'm writing realtime numeric software, in C++, currently compiling it with Visual-C++ 2008. Now using 'fast' floating point model (/fp:fast), various optimizations, most of them useful my case, but specifically: a/b -> a*(1/b) Division by multiplicative inverse is too numerically unstable for a-lot of my calculations. (see: Microsoft...

Creating temporary variables to enhance readability.

I would like to know if there are any significant disadvantages to creating a temporary variable for a value that is accessed multiple times within a small scope. eg: filep->waypt[rp->leg[j]].ID or (*(filep->route + filep->nroutes - 1))->number These are examples from a recent project where I forced myself to avoid almost any simp...

Allocating memory inside loop vs outside loop

Is there noticeable performance penalty for allocating LARGE chunks of heap memory in every iteration of loop? Of course I free it at the end of each iteration. An alternative would be to allocate once before entering the loop, repeatedly using it in all iterations, and eventually freeing it up after exiting the loop. See the code belo...

mysql three joins

Hi, I have a problem with mysql I have 3 tables: Deposit +-------------------+-------------+------+-----+ | Field | Type | Null | Key | +-------------------+-------------+------+-----+ | id | bigint(20) | NO | PRI | | status | int(2) | NO | | | depositDate | datetime |...

Query optimization : Which SELECT syntax is faster?

Hello, Given 5,000 IDs of records fetch in the database, which query , in your opinion is faster? Loop through 5000 IDs using php and perform a SELECT query for each one, foreach($ids as $id){ // do the query $r = mysql_query("SELECT * FROM TABLE WHERE ID = {$id}"); } Or collect all ids in an array, and use SELECT * FROM TABLE...

optimizing a lookup

Hi, I have an array that i use to lookup values. I use the first 2 values to get n rows. for example all rows that have 2 in the first column and 7 in the second. What is the fastest (i mean micro-optimized) way to get these values? I now use a for loop to get the values: int l = SpreadLookupTable.GetLength(0); for (int iCombo = 0; ...

Why aren't whole program optimizations more prevalent now?

Main question: Why aren't general or even specialized whole program optimizers part of our daily lives? I started thinking about this after reading SuperCompilers, LLC's White paper, which discusses their method of "supercompiling" or metacompiling a program's source to (generally) achieve a faster version that does the same functionali...

Help Me with my SQL Query (Need it to always return at least one row.)

First off, here's my SQL query: SELECT research_cost, tech_name, (SELECT research_cost FROM technologies WHERE research_cost <= USERS_RESEARCH_POINTS_VALUE ORDER BY research_cost DESC LIMIT 1) as research_prev, (SELECT cost FROM technology_costs WHERE id = 18 LIMIT 1) as te...

Maximizing Worker Thread Utilization

To solve a problem (and better my understanding of multitasking) I have written a small thread pool implementation. This thread pool spins up a number of worker threads which pop tasks off of a queue as they are added by the client of the thread pool. For the purposes of this question when the task queue is empty the worker threads are a...

How can I improve this php code

Hi, I have a txt file that gets loaded and printed using a class. I'm relatively new to php, so I wonder if the class can be improved and some of the duplicated code (when printing the change-log) can be removed. Here is the class : class changesHandle { public function load($theFile, $beginPos, $doubleCheck) { // Open f...