How to check the number of seconds(or ms) spent inside the particular loop in javascript.
I have a sorting algo implemented in javascript , now I am using bubble sort , I want to use quick sort.
I know in terms of time efficiency Quick sort is good. But I want to calculate the real number of sec or milli sec spent inside the innermost l...
Currently I'm using the following extension method that I made to retrieve the values of elements using LINQ to XML. It uses Any() to see if there are any elements with the given name, and if there are, it just gets the value. Otherwise, it returns an empty string. The main use for this method is for when I'm parsing XML into C# objec...
FYI, This is very similar to my last question: Is there a faster way to check for an XML Element in LINQ to XML?
Currently I'm using the following extension method that I made to retrieve the bool values of elements using LINQ to XML. It uses Any() to see if there are any elements with the given name, and if there are, it parses the val...
FYI, This is very similar to my last question: Is there a faster way to check for an XML Element in LINQ to XML, and parse a bool?
Currently I'm using the following extension method that I made to retrieve the int values of elements using LINQ to XML. It uses Any() to see if there are any elements with the given name, and if there are, ...
I'm looking for an efficient algorithm for detecting equal values in an array of integers N size. It must return the indices of the matches.
Alas, I can't think of anything more clever then brute force with two loops.
Any help will be appreciated.
Thanks!
...
How to calculate the length of a string in C efficiently (in time)?
Right now I'm doing:
int calculate_length(char *string) {
int length = 0;
while (string[length] != '\0') {
length++;
}
return length;
}
But it's very slow compared to strlen() for example, is there any other way to do it?
Thanks.
EDIT: I'm w...
I have a Page class and a PageCollection class in a 3d party ORM framework. I can fill the PageCollection based on parameters (pageid, parentid, url etc..) (SQL query). But I need the data multiple times around the ASP.NET MVC website (Sitemap, Authentication), so I chose to load all pages 1 time and reference that (global) collection.
...
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)?
...
Where can I read about sbrk() in some detail?
How does it exactly work?
In what situations would I want to use sbrk() instead of the cumbersome malloc() and new()?
btw, what is the expansion for sbrk()?
...
The current value of a variable may be "X" or "Y".
A function needs to make sure it is "X".
In general -- with say C integers-- which is more efficient:
"if not X, then set to X"
"just set it to X anyway"
And does that change when the "value" is an Objective-C (immutable) object that has to get re-created?
And in both cases is thi...
ViewHolder pattern improves ListView scrolling framerate, as seen in following example:
http://developer.android.com/intl/de/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html
Is it possible to keep this pattern while using different kind of Views for different rows?
In other words, is it possible to do something ...
I'd like an efficient method that would work something like this
EDIT: Sorry I didn't put what I'd tried before. I updated the example now.
// Method signature, Only replaces first instance or how many are specified in max
public int MyReplace(ref string source,string org, string replace, int start, int max)
{
int ret = 0;
in...
I need to import a list of about 40,000 words into my Iphone app. The list will be the same every time the app starts. It seems that property lists and text files are reasonable options.
Any reason to prefer one over the other? For reasons I don't understand, finder says the property list on my mac is 1MB, while the text file is only...
If I had a large number of functions would it be better to keep them all in one large file or would it be better to separate them into several files of related functions. By better I mean more efficient for both maintainability and for the server processing the request.
For example right now I have all my files in a file named include.p...
Beginners question, on loop efficiency. I've started programming in C++ (my first language) and have been using 'Principles and Practice Using C++' by Bjarne Stroustrup. I've been making my way through the earlier chapters and have just been introduced to the concept of loops.
The first exercise regarding loops asks of me the following...
I am looking for efficent algorithm for checking if one point is nearby another in 3D.
sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2) < radius
This doesn't seem to be too fast and actually I don't need such a big accuracy. How else could I do this?
...
I need to access my cell in the table from tableView:heightForRowAtIndexPath:
since I want to use the data I have ion the custome cell for the height calculations.
The only way I have found to get my cells is to call tableView:cellForRowAtIndexPath:
The problem with that is that calling tableView:cellForRowAtIndexPath: is actually creat...
I've been reading recently about cache-oblivious data structures like auxiliary buffer heaps. These data structures work by keeping their most-recently-accessed elements in cache memory so any subsequent access is also quicker.
Most of these data structures are implemented with a low-level language like C/C++. Is it worth it to try to p...
I find that I myself cannot keep quiet when I present my code to a peer. However, when someone else presents the "business logic" to me while I am looking at the code, it simply does not register in my head - I am just looking at the code.
Now, what can make 1:1 code review more productive? I think this is particularly hard when the cod...
I am using JQuery to append large amounts of text inside a tag. I find the more text currently within the tag the slower appending is, and for large amounts of text it is too slow.
Is there a more efficient way to append text? Such as for instance creating dummy child tags and setting the content of them rather than appending to the par...