optimization

Twitter record size

Hi! Sorry for maybe stupid question;) I am trying to model records like if they were modeled for twitter. It is interesting for me how big or small they are? Is it normal that they can be bigger than 512 bytes per record? And what methods do you know for optimization records within json documents? I mean especial for json;) Maybe some...

Optimizing 1D Convolution

Is there a way to speed up this 1D convolution ? I tried to make the dy cache efficient but compiling with g++ and -O3 gave worse performances. I am convolving with [-1. , 0., 1] in both directions. Is not homework. #include<iostream> #include<cstdlib> #include<sys/time.h> void print_matrix( int height, int width, float *matrix){ ...

When and How Does the Database Slow Down a Site?

I have read a book by O'Reilly that states that 70-80% of the performance of a site can be optimized via the front-end. That may mean that database queries may account to less than 20 or 30% of a site's performance. However, I have seen huge websites like Facebook and Twitter dedicate so much time to optimizing queries (via query caching...

Implementing Scheduling Algorithms with Java

has anyone of you ever dealt with job scheduling problems with Java? I have to work on a resource-constrained project scheduling problem and want to ask for some practical tips. Are there any good libs available for implementing algorithms? What are efficient data structures I should use? edit: It seems like i have not explained it rig...

What's the fastest way to clear the isolatedstoragestore for a windows phone 7 application?

I'm currently working on an application which writes data to the IsolatedStorageStore. As part of the app, I'd like to implement a "clear all data/reset" button, but enumerating through all the files that exist and all the folders that exist is taking quite a bit of time. Is there a magic "reset" method or something I can use, or should ...

Merging pixels to minimize paint operations on Html canvas

Hi I'm painting an image onto a canvas (html5) and I want to reduce the number of fillRect calls I'm making in the hope of making the process more efficient. Note: I'm calling canvas.fillRect to paint individual pixels and pixels can be 1x1 or other size rectangle depending on resolution I'm painting in (So I know that they are not call...

Need Cost Minimization Algorithm for USPS Flat Rate Boxes

I have a client who ships fluids in USPS flat rate boxes. If you are unfamiliar with USPS flat rate boxes, they are boxes of a certain volume that ship regardless of weight. Anything that fits in the box, ships for one low price. My client uses two box sizes: the medium flat rate boxes, and the large flat rate boxes. Additionally, my cli...

Difference between constrained optimization and unconstrained optimization problems?

What is the property that makes an optimization problem unconstrained? ...

php speed with if statements

So I'm working on a project written in old-style (no OOP) PHP with no full rewrite in the near future. One of the problems with it currently is that its slow—much of the time is spent requireing over 100 files based on where it is in the boot process. I was wondering if we could condense this (on deployment, not development of course) i...

Merge two Hash Maps Android

Hi guys, I want to merge Two HashMaps. I could use map1.putAll(map2); but I don't want to overwrite the key's as yes they will have conflicting keys. So the keys in each map will be like this word1 word1 word2 word2 word3 word3 and when I merge them I would like: word1 word2 word3 word4 word5 word6 It c...

How to optimize this suboptimal Set-Cover solution?

I wrote this program to test how long it would take to "solve" the set-cover problem. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; using MoreLinq; namespace SetCover { class Program { const int maxNumItems = 10000; const int numSets = 5000; ...

Can large String Arrays freeze my program?

Hello, I recently created a program that gets medi-large amounts of xml data and converts it into arrays of Strings, then displays the data. The program works great, but it freezes when it is making the arrays (for around 16 seconds depending on the size). Is there any way I can optimize my program (Alternatives to string arrays etc.)...

Multiple parameter optimization with lots of local minima

I'm looking for algorithms to find a "best" set of parameter values. The function in question has a lot of local minima and changes very quickly. To make matters even worse, testing a set of parameters is very slow - on the order of 1 minute - and I can't compute the gradient directly. Are there any well-known algorithms for this kind o...

Fast undo/redo for bitmap editor when memory is limited?

I'm trying to write a bitmap editor for a mobile device (i.e. a limited version of Photoshop). The user's document consists of ~4 bitmaps around 1000x500 in size each. I want a robust and efficient undo/redo system that's as simple as possible. I'm aiming for about ~0.2s to undo or redo an edit. I'm looking for some feedback on my curre...

Strange behaviour of JOIN

Hi all, I have a strange problem with my query trying to join 3 tables. The tables descibed: 2 similar tables like this (entr_es): Field Type Null Key Default Extra espid int(11) NO PRI NULL auto_increment haslo text NO MUL NULL kat int(11) NO NULL The second table looks the same, except the first colum...

How do compilers optimize our code?

Hi, I ran into this question when i was answering another guys question. How do compilers optimize the code? Can keywords like const, ... help? Beside the fact with volatiles and inline functions and how to optimize the code all by your self! ...

Converting while to generator 3.4 times slow down

What is happening? Can somebody explain me what happens here, I changed in tight loop: ## j=i ## while j < ls - 1 and len(wordlist[j]) > lc: j+=1 j = next(j for j in range(i,ls) if len(wordlist[j]) <= lc) The commented while version ran the whole program: 625 ms, the next generator version ran the wh...

MySQL inclusion/exclusion of posts

This post is taking a substantial amount of time to type because I'm trying to be as clear as possible, so please bear with me if it is still unclear. Basically, what I have are a table of posts in the database which users can add privacy settings to. ID | owner_id | post | other_info | privacy_level (int value) From there, users c...

MySQL how to store data + access permissions performance-wise

I've recently came across a problem for which I can only think of muddy solutions. Imagine a table has several objects (lets say photos to make it easier). Every single photo/object must have it's own set of permissions. 1 - photo must always be seen by uploader 2 - photo belongs to a group of photos and all users that have access to t...

Max element count in WPF application for performance

Hi, In a WPF line of business application, at which point should I consider that the count of Elements, as seen in snoop, will noticebly hit performance. In Advanced WPF Application Performance, the speaker looks at an application with ~6400 elements and says : fairly heavy but not necessarly unusual. On my part I have an application ...