optimization

Is choosing proper collection type premature optimization ?

Hi, Recently I'm encountering this type of code ever more frequently: List<Something> list = new LinkedList<Something>(); // add a bunch of constants to the list // keep in mind that the number of items added is known on list creation return list.toArray(new Something[list.size()]); Now in my honest opinion this is improper use of th...

Performance of find() vs. for loop

I've got a large (4000 values) set of unsorted, normally distributed points. I'm taking each of these data points into bins whose limits are in the BinLimit array. Then I'm tabulating the number of values in each bin. X is the array of raw data, and N is the number of data points. The number of bins desired (TotalBins) is specified by t...

Optimal redundancy

A mission-critical production system has n stages that have to be perfomed sequentially; stage i is performed by machine M_i. Each machine M_i has a probability f_i of failing and a probability 1 - f_i of functioning reliably (and the failures are independent). Therefore, if we implement each stage with a single machine, the probability ...

Mysql benchamrking GUI tool

Hi I need to optimize an application which is already there for a long time. Optimization will include move inline queries from php pages to "stored procedures", get rid of sub queries and convert them to "joins" etc etc. I guess the best way is to use benchmarking tools for this purpose, but is there any GUI based tool available which ...

How could I optimise this MySQL query?

I have a table that stores a pupil_id, a category and an effective date (amongst other things). The dates can be past, present or future. I need a query that will extract a pupil's current status from the table. The following query works: SELECT * FROM pupil_status WHERE (status_pupil_id, status_date) IN ( SELECT status_pupil_id,...

how to handle optimizations in code

I am currently writing various optimizations for some code. Each of theses optimizations has a big impact on the code efficiency (hopefully) but also on the source code. However I want to keep the possibility to enable and disable any of them for benchmarking purpose. I traditionally use the #ifdef OPTIM_X_ENABLE/#else/#endif method, b...

Benefits and drawbacks for CAAnimationGroup vs. CAKeyframeAnimation.

Dear fellow Stackers, I'm currently working on some core animation stuff for the iOS and really enjoying myself. This question is regarding the many different ways one can implement an animation. Say you would like to rotate a UIView a few times but with different timing functions for each animation cycle. To the best of my knowledge th...

Is it possible to improve the performance of this drawing technique?

Am currently working on a tool created by a colleague of mine and would like to improve performance. Basically, it's a tool for drawing on screen and uses a combination of Sprites and the Graphics class to draw a line segment every time the mouse is moved when the mouse button is down. Here is the drawing bit: // on MouseMove protected...

Restricted optimization of custom functions in R

I have a complicated combined model for which I can define a likelihood in a function, and I need to optimize the parameters. Problem is, the parameters go all directions if not restricted. Hence, I need to implement a restriction on the parameters, and the one proposed by the professor is that the sum of squared parameter values should ...

mysql optimisation

Hi guys, I have a photo gallery with 1.5 million photos so we are talking a big database. We want to make it so that people once they have uploaded a photo can upload into several different areas of the site. Photos also have attributes and tags and we have a tables for that as well. here is the layout PHOTO TABLE photo_id image status...

2-opt algorithm for traveling salesman problem in C programming

Hello Can someone give me a code sample of 2-opt algorithm for traveling salesman problem in C programming.. ...

Optimizing Actionscript performance

I am setting out for a visualization project that will generate 1000+ sprites from dynamic data. The toolkit I am using (Flare) requires some optimization. I am trying to figure out some optimization techniques for Flash. How can I make Flash run fast when there are so many sprites on the stage, or maybe there is an optimization techniqu...

how to optimize a left join query?

I have two tables, jos_eimcart_customers_addresses and jos_eimcart_customers. I want to pull all records from the customers table, and include address information where available from the addresses table. The query does work, but on my localhost machine it took over a minute to run. On localhost, the tables are about 8000 rows each, but ...

Why not mark everything inline?

First off, I am not looking for a way to force the compiler to inline the implementation of every function. To reduce the level of misguided answers make sure you understand what the inline keyword actually means. Here is good description, inline vs static vs extern. So my question, why not mark every function definition inline? ie ...

Streaming 3D characters over low-bandwidth line

Hi, I'm looking for some protocol or approach to stream a single 3D character (might be even low-poly) from a server to a client + simple animation for the character. Example - a monster + simple animation for his "roar". The animation is also 3D and uses the 3D character only. Any ideas? Thanks! ...

Best way to suppress OpenGL ES (iPhone) texture / OpenAL sounds memory footprint?

What should i do? I have some 512x512 png. I compressed them to PVR (which results terrible quality), and I'm preparing to compress the PNGs with pngcrush tool. The PVRs have about 2x-x larger filesize than the PNGs, maybe I can experiment with JPG files. Are the images stored in a compressed state in memory? Or compression counts only ...

A traveling salesman like problem

Given a set of points in the 2D Euclidean plane: P={V1,V2,..,Vn}, and we assume that there are K different types of points:T1,T2,..,TK, every point Vi in P belongs to exactly one of the K types. Definition of KTSP tour: Given an arbitrary location point V0 in the same 2D Euclidean plane (V0 has no type), a path V0->V'1->V'2->V'3->....-...

Rails active record type for types that are within a group.

This is more of a design question. I have several places in models were I have records that have only a certain amount of option for them, for example: Sex: There is only 2 options (male, female) Level: There is only 3 options (silver, gold, platinum) Country: There is only a limited amount of countries. My question is what is the righ...

Opinions on possible optimization for a web application using javascript

I'm thinking of implementing my web application in a certain way as an optimization, and I'd like to get people's opinions on whether this is a good idea or not. Here's the details: For most of my pages, instead of determining server side whether the user is logged in, and then modifying the page I send based on that, I want to send the...

Using a db vote table for many arguments tables

Hi, I'm trying to understand if it's right to use one table for votes for more than one argument: table_votes id | vote (±1) | id_user | timestamp | argument_type | argument_id table_photos // could be argument_type = 1 id | photo_file | photo_name | etc. table_house // could be argument_type = 2 id | house_name | etc. My prob...