optimization

Slow string concatenation over large input

I've written an n-ary tree ADT which works fine. However, I need to store its serialization in a variable a calling class. eg. DomTree<String> a = Data.createTreeInstance("very_large_file.xml"); String x = a.toString(); I've written method which serves the purpose exactly how I need it, but on very large inputs it takes forever (2...

Need ways to speed up PHP methods

I ended up creating my own HTML class, mainly to keep all our output consistent. The code is below. <?php /** * A class to generate html tags * @author Glen Solsberry */ class HTML { private $isOpen; /** * holds all information about tags * @var $tags array */ private $tags; private $current_tag = 0;...

Measuring iPhone application load time

I am in the process of optimizing an iPhone app for very short load time and am wondering: Is there a means of measuring the load time of an iPhone app from the time the user taps the icon to the time that the app is usable (or at least –viewDidLoad gets called)? Ideally this would work in the device and simulator, but if someone has ...

Planning a 2D tile engine - Performance concerns

As the title says, I'm fleshing out a design for a 2D platformer engine. It's still in the design stage, but I'm worried that I'll be running into issues with the renderer, and I want to avoid them if they will be a concern. I'm using SDL for my base library, and the game will be set up to use a single large array of Uint16 to hold the...

Optimisation techniques for sqlite database

I'm creating Android application that contains a large amount of data. It takes lot of time to access the data. What are optimization technique that I can use ? Are there any optimized queries? ...

C coding practices for performance or code size - beyond what a compiler does

I'm looking to see what can a programmer do in C, that can determine the performance and/or the size of the generated object file. For e.g, 1. Declaring simple get/set functions as inline may increase performance (at the cost of a larger footprint) 2. For loops that do not use the value of the loop variable itself, count down to zero in...

Slow implementation of famous compression algorithm (LZ78)

I'm writing a method which approximates the Kolmogorov complexity of a String by following the LZ78 algorithm, except instead of adding to a table I just keep a counter i.e i'm only interested in the size of the compression. The problem is that for large inputs it is taking hours. Is it the way I have implemented it? /** * Uses the ...

slow implementation of Union and Intersection

I'm trying to find a better way to implement these methods, as over very large sets they take a very long time, any ideas? import java.util.HashMap; import java.util.HashSet; public class Multiset<E> extends HashSet<E> { private static final long serialVersionUID = -9013417064272046980L; private HashMap<E, Integer> multiplicit...

Is Perl faster than bash?

I have a bash script that cuts out a section of a logfile between 2 timestamps, but because of the size of the files, it takes quite a while to run. If I were to rewrite the script in Perl, could I achieve a significant speed increase - or would I have to move to something like C to accomplish this? #!/bin/bash if [ $# -ne 3 ]; then ...

Speeding up GTK tree view

I'm writing an application for the Maemo platform using pygtk and the rendering speed of the tree view seems to be a problem. Since the application is a media controller I'm using transition animations in the UI. These animations slide the controls into view when moving around the UI. The issue with the tree control is that it is slow. ...

How do I set SuppressUnmanagedCodeSecurity for callbacks?

When using P/Invoke, adding [SuppressUnmanagedCodeSecurity] can speed calls from managed code into unmanaged code in trusted scenarios. Is there a way to accomplish the same thing in the reverse direction, to speed things up when I call from unmanaged code back into managed code? Profiling shows a much higher overhead going in that dir...

VB.NET: Optimize initialisation of multiple classes

In a project of mine I'm currently doing this: addTemplateToList(New docNULL) addTemplateToList(New docAgenda) addTemplateToList(New docAgendaNew) addTemplateToList(New docOffer) : 20 more : addTemplateToList(New docRequest) all classes inherit docMain and addTemplateToList( X ) adds x to a List(Of do...

slow construction of tree structure from XML

I'm parsing an XML document into my own structure but building it is very slow for large inputs is there a better way to do it? public static DomTree<String> createTreeInstance(String path) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstanc...

Multi column distinct in mysql

| one | two | ------------- | A | 1 | | A | 2 | | B | 1 | | B | 3 | | C | 1 | | C | 4 | I would like to get no repeats in any column in a query, so the standard SELECT DISTINCT one,two FROM table; or SELECT * FROM table GROUP BY one,two; doesn't quite work, because it looks for distinct in all rows, which in th...

Multiple ParticleSystems in cocos2d

I wonder about what road I should go with ParticleSystem. In this particular case I want to create 1-20 small explosions at the same time but with different positions. Right now I'm creating a new ParticleSystem for each explosion and then release it, but of course this is very punishing to the performance. My question is: Is there a wa...

C/C++ rounding up decimals with a certain precision, efficiently

I'm trying to optimize the following. The code bellow does this : If a = 0.775 and I need precision 2 dp then a => 0.78 Basically, if the last digit is 5, it rounds upwards the next digit, otherwise it doesn't. My problem was that 0.45 doesnt round to 0.5 with 1 decimalpoint, as the value is saved as 0.44999999343.... and setprecisi...

SQL Database design help needed

I am trying to limit the about of tables in my database because I hear that's good (I am a novice web developer). I want to have the user input a list into the database. So they input a title, overall comment, and then start making the list. I can't figure out how to do this without making a new table for each list. Because, say one user...

What steps can I take to optimise build times in TeamCity?

I'm currently trying to reduce the time taken to compile and unit test projects in TeamCity. Currently my project takes about between 5 to 8 minutes to build. What it does is: Clean any existing files Compile each project Create the installer Once that is done the unit tests are kicked off and it takes about 2 minutes to run. What...

How to resolve opposing interests of optimization vs accessibility?

I've spend a fair amount of time on website optimization (YSlow, Google's Page Speed, etc), and now I'm thinking more and more about improving the accessibility of my websites. However, it seems like that they are competing interests at times. If I include separate style sheets for screen readers, mobile devices, etc, those are additio...

Prioritise ASP.NET requests

Hello I would be surprised if this is possible, but you never know. Is there a way in which I could prioritise ASP.NET requests? For example, if the request is a NEW request (coming from Location X) I would like it to take priority over a request coming from a known location. This will be running under IIS 7 so can I make use of the ...