optimization

Reducing graph data without losing graph shape

I have a dataset with 100 000 datapoints which I have to plot on a graph. The resulting graph will be about 500px wide, so for every pixel there will be about 200 datapoints, which seems quite unnecessary. I need to find a way to get rid of the excess datapoints without losing the shape of the graph to speed up the rendering. Currently ...

Can anyone work out a more optimised SQL solution?

I am worried this is a bit expensive. Plus I will soon implement a normalized system for the tags so there will be additional joins. On top of that I have 4 tables (tbl_videos, tbl_articles, tbl_galleries and tbl_users) of which I want to display three results of each and thus will have to run the query four times on one press of 'se...

Actionscript optimisation confusion

Hi, EDIT: Ah ha! The solution to my problem was simple afterall! I'm an idiot :D I was so focused on why it was taking so long, that I was blinded by the fact that my object pool allocate() function is lazily evaluated. i.e. It won't allocate until it's called. But my timer test was around alloc, so obvious the first time through, th...

Which of those two pieces of code is better/faster/uses less memory?

Which one is more optimal or is there any difference at all? String s = methodThatReturnsString(); int i = methodThatReturnsInt(); thirdMethod(s, i); or thirdMethod(methodThatReturnsString(), methodThatReturnsInt()); By optimal I mean optimal in the terms of memory usage etc. ...

Is it really worth it to normalize the "Toxi" way? ( 3NF )

I'm in the early stages of my database design so nothing is final yet, and I'm using the "TOXI" 3-table design for my threads which have optional tags, but I can't help but feel that the joining is not really necessary and perhaps I need to just rely on a simple tags column in my posts table where I can just store a varchar of something ...

is there such thing as a query being too big?

I don't have too much experience with SQL. Most of the queries I have written have been very small. Whenever I see a very large query, I always kinda assume it needs to be optimized. But is this true? or is there situations where really large queries are just whats needed? BTW when I say large queries I mean queries that exceed 1000+ ch...

VB.Net Function Optimization (SSRS Report Code)

I came across the following code recently and would like to optimize it: Public Shared Function ComputeLabel(ByVal Action As Integer, ByVal Flag1 As Boolean, ByVal Flag2 As Boolean) As String Dim Prefix As String = "" If Flag2 Then Prefix = "Conditional " ElseIf Flag1 Then Prefix = "Held " End If Select Case...

SSRS Code Shared Variables and Simultaneous Report Execution

We have some reports that are failing when two of them are executed very close together. I've found out that if two instances of an SSRS report run at the same time, any Code variables declared at the class level (not inside a function) can collide. I suspect this may be the cause of our report failures and I'm working up a potential fi...

Fastest way to list all primes below N in python

This is the best algorithm I could come up with after struggling with a couple of Project Euler's questions. def get_primes(n): numbers = set(range(n, 1, -1)) primes = [] while numbers: p = numbers.pop() primes.append(p) numbers.difference_update(set(range(p*2, n+1, p))) return primes >>> timeit....

How does one optimize performance when creating or removing dozens of divs with JQuery?

Background: In the current project I am working on, I have created a jquery plugin that creates a draggable 'google-maps'-esque map, made up of many tiles. Similar to how google map works, but without the zoom at this point. This map plugin creates and destroys 10-20 <div> tiles per mouse being dragged one tile length using jQuery's $(...

HTML validation and loading times

Does having (approx 100) HTML validation errors affect my page loading speeds? Currently the errors on my pages don't break the page in ANY browser, but I'd spend time and clear those anyhow if it would improve my page loading speed? If not on desktops, how about mobile devices like iPhone or Android? (For example, N1 and Droid load pag...

Can we simplify this string encoding code (C#)

Is it possible to simplify this code into a cleaner/faster form? StringBuilder builder = new StringBuilder(); var encoding = Encoding.GetEncoding(936); // convert the text into a byte array byte[] source = Encoding.Unicode.GetBytes(text); // convert that byte array to the new codepage. byte[] converted = Encoding.Convert(Encoding.Un...

Freelists with concurrent allocators

Freelists are a common way to speed up allocation by reusing existing memory that was already allocated. Is there a way to use free-lists in a concurrent allocator, without incurring the overhead of a lock for every allocation (which would neutralize the intended performance gain of the freelist)? ...

Coding Practices which enable the compiler/optimizer to make a faster program.

Many years ago, C compilers were not particularly smart. As a workaround K&R invented the register keyword, to hint to the compiler, that maybe it would be a good idea to keep this variable in an internal register. They also made the tertiary operator to help generate better code. As time passed, the compilers matured. They became v...

sql server delete slowed drastically by indexes

I am running an archive script which deletes rows from a large (~50m record DB) based on the date they were entered. The date field is the clustered index on the table, and thus what I'm applying my conditional statement to. I am running this delete in a while loop, trying anything from 1000 to 100,000 records in a batch. Regardless of ...

How to compute the absolute minimum amount of changes to convert one sortorder into another?

Goal How to encode the data that describes how to re-order a static list from a one order to another order using the minimum amount of bytes possible? Original Motivation Originally this problem arose while working on a problem relaying sensor data using expensive satellite communication. A device had a list of about 1,000 sensors th...

Help Me optimize this code?

I am looking to se if this code can be optimized. def gB(a,b,c): x=len(b) d=a.find(b)+x e=a.find(c,d) return a[d:e] print gB("abc","a","c") ...

SQL Server 2000 Table Optimization

Hi, Ive been working all day on optimizing a SQL Server 2000 db table with ~9million rows. My only db experience has been with tables with a few hundred rows, so I've never really had to deal with optimization. I am doing selects and updates based on a 21 digit number. Using an indexed char(21) type, the queries take more then 2 secon...

Generate a random binary number with a variable proportion of '1' bits

I need a function to generate random integers. (assume Java long type for now, but this will be extended to BigInteger or BitSet later.) The tricky part is there is a parameter P that specifies the (independent) probability of any bit in the result being 1. If P = 0.5 then we can just use the standard random number generator. Some oth...

Optimize a list of text additions and deletions

Hello, I've got a list containing positions of text additions and deletions, like this: Type Position Text/Length 1. + 2 ab // 'ab' was added at position 2 2. + 1 cde // 'cde' was added at position 1 3. - 4 1 // a character was deleted at position 4 T...