Memory access through pointers is said to be more efficient than memory access through an array. I am learning C and the above is stated in K&R. Specifically they say
Any operation that can be achieved by array subscripting can also be done with pointers. The pointer version will in general be faster
I dis-assembled the following ...
I've recently been writing some code for a research project that I'm working on, where efficiency is very important. I've been considering scraping some of the regular methods I do things in and using bitwise XORs instead. What I'm wondering is if this will make if a difference (if I'm performing this operation say several million times)...
I am working in a chemistry/biology project. We are building a web-application for fast matching of the user's experimental data with predicted data in a reference database. The reference database will contain up to a million entries. The data for one entry is a list (vector) of tuples containing a float value between 0.0 and 20.0 and an...
I am wondering would this make any real efficieny difference (ie computation time, memory etc..)
This is my model:
class FooUser(models.Model):
name = models.CharField(max_length=50)
sirname = models.CharField(max_length=50)
Assume I have 2 different approaches while saving a FooUser at a view:
First one, assigning retrieved ...
Hi all,
I'm working on a Qt-based MacOS/X audio metering application, which contains audio-metering widgets (potentially a lot of them), each of which is supposed to be updated every 50ms (i.e. at 20Hz).
The program works, but when lots of meters are being updated at once, it uses up lots of CPU time and can bog down (spinny-color-whee...
Hello I am trying to get the efficiency for Strassen's algorithm but need some help.
The recurrence relation for the algorithm is the following:
A(n) = 7A(n/2)+18(n/2)^2, for n>1, A(1) = 0.
I've solved it to the point where I have
a(n) = 6( 7^(log base(2) n) - 4^(log base(2) n) )
Does this mean the efficiency of the algorithm is...
Should I plan to parse/regex, for example, an entire url string retrieved from one field of a database table during a while loop of query results using PHP?
Or should I store segments of the data (directory, filename, extension) in their own separate fields and concatenate the results during a while loop of query results?
Assuming wo...
I am seeking your stories on how you have streamlined your client side development with Visual Studio. In particular, it seems that I need to build my site too often in order for changes to pushed down to IE effectively. What shortcuts or tools like FireBug, etc. do you use for your client side development? Do you avoid Visual Studio ...
Hi,
I'm using Linq to SQL and read in a blog post about closing database connections as soon as possible. As an example, they showed a variable being converted to a list (using .ToList()) instead of actually returning the Linq query. I have the below code:
public static bool HasPassword(string userId)
{
ProjDataContext db = new...
I have a basic question about assembly.
Why do we bother doing arithmetic operations only on registers if they can work on memory as well?
For example both of the following cause (essentially) the same value to be calculated as an answer:
Snippet 1
.data
var dd 00000400h
.code
Start:
add var,0000000Bh
mov ea...
Hi,
I've nearly finished the development of a project and would like to test its performance, especially the database query calls. I'm using Linq to SQL to search via usernames, but I've only got around 10 'users' in my database, so I can't really get a decent speed reading. How can I simulate thousands/millions of users in the databas...
I am attempting to troubleshoot a slow running stored procedure in SQL Server 2005. I am analyzing the execution plan and see a SORT that is 45%, but I am not using an ORDER clauses. What would be causing this.
UPDATE SP (cleaned up, and made change on OR's)
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Rp...
I would like to retrieve an ordered query result, but I need to have some specific row(s) to be in front of the list. Something like here on Stack Overflow, in the list of answers the right answer is always the first one.
Assumed I need to have the rows with IDs 1,2,3 to be the head, the rest sorted by a date field, is it possible to do...
hi,
I'm using Linq to SQL to access my database. I want to have a 'delete account' feature which basically gets rid of all records in all tables that belong to a given user. What would be the most efficient way of doing this? The deletion has to occur in a certain order, otherwise there are foreign key integrity errors. I can do this m...
I've got an array that contains combinations of unique MySql IDs:
For example:
[
[1,10,11],
[2,10],
[3,10,12],
[3,12,13,20],
[4,12]
]
In total there are a couple hundred different combinations of IDs.
Some of these combinations are "valid" and some are not. For example, [1,10,11] may be a valid combination, whereas [3,10,12] m...
Hi,
Am I missing something in the Array documentation? I have an array which contains up to one object satisfying a certain criterion. I'd like to efficiently find that object. The best idea I have from the docs is this:
candidates = my_array.select { |e| e.satisfies_condition? }
found_it = candidates.first if !candidates.empty?
B...
I have an array of points in unknown dimensional space, such as:
data=numpy.array(
[[ 115, 241, 314],
[ 153, 413, 144],
[ 535, 2986, 41445]])
and I would like to find the average euclidean distance between all points.
Please note that I have over 20,000 points, so I would like to do this as efficiently as possible.
Thanks.
...
I guess this is a common Problem:
consider an application where Users have a Role
You will likely have something like
User
username : String
role : String
but in your database you have
CREATE TABLE IF NOT EXISTS roles (
role_id TINYINT(1) UNSIGNED AUTO_INCREMENT,
role_name VARCHAR(10) NOT NULL,
PRIMARY KEY...
If I want to allocate millions of objects of a class Foo, and I want to be memory- and time-efficient, how should I design the Foo class?
Obviously, Foo should not contain much member data.
Also, I guess, it should not use virtual functions?
And how costly is it for Foo to derive from a Base class? And from several Base classes?
...
After coming across the code golf trivia around the site it is obvious people try to find ways to write code and algorithms as short as the possibly can in terms of characters, lines and total size, even if that means writing something like:
//Code by: job
//Topic: Code Golf - Collatz Conjecture
n=input()
while n>1:n=(n...