suppose i a have a multiplicative expression with lots of multiplicands (small expressions)
expression = a*b*c*d*....*w
where for example c is (x-1), d is (y**2-16), k is (x*y-60)..... x,y are numbers
and i know that c,d,k,j maybe zero
Does the order i write the expression matters for faster evaluation?
Is it better to write c*d*...
So what I am trying to do with this code is find all pixels on a line of an image that are below a certain threshold. The problem, however, is that this code is executed in a double for loop (yeah I know :( ), once for each pixel, so it's very slow. I'm wondering if there's anything else I can do.
Some tips would be great, as I'm pretty...
Hello, I'm having the following problem:
I'm developing a C# application which requires unsafe code to call an unmanaged c++ function. The structure is:
[StructLayout(LayoutKind.Sequential)]
unsafe struct DataStruct
{
public UInt16 index;
public UInt16 response;
public byte* addr; //this is a pointer to a byte array which s...
I've just noticed that my app is including over 148 php files on one page. Bear in mind this is the back end admin and not the main site, but is this too many? What impact does a large number of includes have on a server, both whilst under average load and stressed? Would disk I/o be a problem?
Included File Stats
File Type - Include C...
take two following classes and their constructors as samples:
class One{
public:
One(int a,int b):adad1(a),adad2(b){}
private:
int adad1;
int adad2;
};
class Two{
public:
Two(int input[]){
for (int i=0;i<10;i++)
araye[i]=input[i];
}
private:
int araye[10];
};
considering objects with static storage duration, I t...
I have an application that holds huge number of instances in-memory for performance reasons, and I don't want to write it to disk or any other place, just hold it all in-memory.
public class MyObject
{
public string Name;
public object Tag;
public DateTime DateTime1;
public DateTime DateTime2;
public DateTime DateTi...
What is a fast way to compute the (long int) ceiling(log_2(i)), where the input and output are 64-bit integers? Solutions for signed or unsigned integers are acceptable. I suspect the best way will be a bit-twiddling method similar to those found here, but rather than attempt my own I would like to use something that is already well test...
So, I'm reading through the YUI best practices for speeding up your web page, and I'm using PHP to try and implement some of those suggestions. Here is what I have so far:
<?php
// Expires one year from now
$expires = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1);
// Format date
$date = date('D, d M Y H:i:s', $expires);
// Se...
There are a lot of different classes that can be used in various ways to read/write to files in Android. For example, you can make use of java.nio.ByteBuffer, FileOutputStream and BufferedOutputStream. Are there any general guidelines for what to use to read/write quickly to the SD card? For example, BufferedOutputStream seems as if it s...
In liberal C:
/* i'm using this */
struct QueueItem
{
QueueItem* next;
void* data;
}
struct Queue
{
QueueItem* head;
QueueItem* tail;
}
/*
+---+ +---+
|0 0| |* *| len 1
+---+ +|-|+
v v
len +---+
0 |d 0|
+---+
+---+
|* *------...
In implementing the backup script I described in this serverfault question, I ran into some timeout issues that have prompted optimizations to the code (namely, backing up one file per execution of the script and doing everything I can to minimize the number of file-hashes I am calculating over the very large data files).
So far, that ...
I'm writing some Clojure code that depends upon a number of constants.
They will be used within tight inner loops, so it's important that they will be used and optimised as efficiently as possible by the Clojure compiler+JVM combination. I would normally used a "public static final" constant in Java for the same purpose.
What is the be...
I have some code that runs fairly well, but I would like to make it run better. The major problem I have with it is that it needs to have a nested for loop. The outer one is for iterations (which must happen serially), and the inner one is for each point particle under consideration. I know there's not much I can do about the outer on...
I need to quickly extract text from HTML files. I am using the following regular expressions instead of a full-fledged parser since I need to be fast rather than accurate (I have more than a terabyte of text). The profiler shows that most of the time in my script is spent in the re.sub procedure. What are good ways of speeding up my proc...
My members will have the ability to customise their profile page with X amount of widgets, each widget displays different data such as a list of music, list of people they are following etc.
Several widgets include:
- List of media they have uploaded
- List of people they are following
- List of people following them
- Html/Text wid...
Hi,
Since IEnumerable.Contains() method does not accept a predicate as an argument, Most people use the following code to check the existence of something matching a condition:
// ProductId is unique.
if (Products.Count(c => c.ProductId = 1234) == 1)
{
// Products list contains product 1234.
}
This code forces to walk through eve...
I have the next class which instantiated about 40 million times and all its instances take about 80% of all process memory (more than 15GB).
class MyClass
{
String Field1
String Field2
String Field3
int Field4
int Field5
float Field6
SomeEnum Field7
Boolean Field8
Boolean Field9
Boolean Field10
...
Query below takes 20 seconds to run. user_table has 40054 records. other_table has 14000 records
select count(a.user_id) from user_table a, other_table b
where a.user_id = b.user_id;
our restriction is that any query running more than 8 seconds gets killed...>_< I've ran explain plans, asked questions here but based on our restrictio...
Hi !
I am working with a huge database and trying top optimize it.
I was wondering if it will make any change to index the values that are used as criteria in the request, but through a function.
For example I have this GPS coordinate table :
-Node (#id,lat,lng)
and this request :
SELECT * FROM Node WHERE distance( lat, lng, $lat, ...
First of all, I don't have multiplication, division operations so i could use shifting/adding, overflow-multiplication, precalculations etc. I'm just comparing one n-bit binary number to another, but according to algorithm the quantity of such operations seems to be huge. Here it is :
There is given a sequence of 0's and 1's that is di...