efficiency

Using Cloud/Distrubted computing to share processor time - possibilities and methods

My question is one I have pondered around when working on a demanding network application that would explicitly share a task across the network using a server to assign the job to each computer individually and "share the load". I wondered: could this be done in a more implicit manner? Question Is there a possibility of distributing p...

Most efficient way to parse this with the Java Scanner library?

I'm trying to parse a section of a large file with Java's Scanner library, but I'm having a hard time trying to determine the best route to parse this text. SECTOR 199 FLAGS 0x1000 AMBIENT LIGHT 0.67 EXTRA LIGHT 0.00 COLORMAP 0 TINT 0.00 0.00 0.00 BOUNDBOX 7.399998 8.200002 6.199998 9.399998 8.500000 7.099998 COLLIDEBOX 7.605121 8.2307...

mysql deletion efficiency

I have a table with large amount of data. The data need to be updated frequently: delete old data and add new data. I have two options whenever there is an deletion event, I delete the entry immediately I marked delete the entries and use an cron job to delete at unpeak time. any efficiency difference between the two options? or an...

In python, looking for an alternative to Shelve (too slow for large dictionaries).

I am storing a table using python, and I need persistance. Essentially I am storing the table as a dictionary string to numbers. And the whole is stored with shelve self.DB=shelve.open("%s%sMoleculeLibrary.shelve"%(directory,os.sep),writeback=True) I use writeback to true as I found the system tend to be unstable if I don't. So aft...

Correct way to add objects to an ArrayList

I am trying to add an object to an arraylist but when I view the results of the array list, it keeps adding the same object over and over to the arraylist. I was wondering what the correct way to implement this would be. public static ArrayList<Contact> parseContacts(String responseData) { ArrayList<Contact> Contacts = new Arra...

Efficiency of Preg_replace

Executive Summary: preg_replace() ran faster than string comparisons. Why? Shouldn't regular expressions be slower? In a recent question about detecting any of an array of disallowed substrings within a given input, I suggested comparing the result of a preg_replace() call to the original input, since preg_replace() can take an array...

SurfaceView vs Custom View (extended from View). SurfaceView is slower, Why?

I wrote the same program two ways. One using a Surfaceview, and the other using a custom view. According to the android SDK development guide, using a surface view is better because you can spawn a separate thread to handle graphics. Th SDK development guide claims that using a custom view with invalidate calls is only good for slower a...

All languages - Procedural Efficiency

Hi Consider these to options if(successful) { if(condition) { //do something } if(condition) { //do something } ... } or if(successful)&&(condition) { //do something } if(successful)&&(condition) { //do something } ... Imagine there 100 if statements. Is there any difference in effi...

Python efficiency of and vs multiple ifs

Is there an efficiency difference between using and in an if statement and using multiple if statements? In other words, is something like if expr1 == expr2 and expr3==expr4: dostuff() different from an efficiency standpoint then: if expr1 == expr2: if expr3 == expr4: dostuff() My very basic testing does not reveal a diffe...

More efficient way of querying for this data?

I have a table with some data in it: ColA | ColB | ColC ------+------+------ 1 | A | X 2 | A | Y 3 | B | Y 4 | C | Y 5 | C | Z 6 | D | Y 7 | D | Z I want to query to get all of the rows where ColB and ColC as a pair match a condition: SELECT * FROM [Table] WHERE (ColB = A AND...

Is a touchscreen useful/effective while programming?

Does anyone have experiences if working with a touch screen monitor is useful and effective while programming? I mean most things an effective programmer will do with the keyboard, but I wonder if the other things (clicking through menus, scrolling through compilation logs, and of course copy'n'paste) can be done more efficiently with a ...

MySQL: Most efficient data type to store long notes?

I was wanting to create a personal note database, to store notes in HTML or text that are quite long. What would be the difference between VARCHAR and TEXT fields, which one would be more efficient to use? I think VARCHAR's max is 65535 characters, I can't wrap my head around if I'll contain anything larger than that though. I wonder if...

Efficiency of explicit initialization

I have a class which has a constructor that takes a const char*. It is: c::c(const char* str) { a = 32; f = 0; data = new char[strlen(str)]; memcpy(data, str, strlen(str)); } And a function which takes one of them: int foo(c& cinst); You can call this function either by passing it an instance of a c: c cinst("asdf"...

Should a C# accessor use a private variable or calculate on the fly?

Which is a better programming practice and why? I have a class like this: class data { public double time { get; internal set; } public double count { get; internal set; } public average_count { ... } } Where average_count should be read_only and give a calculation of count / time. Is it better to write the accessor as...

Effective way of forming a Java WebService client

Which is more effective way of forming a WebService client out of the following ? Having the Service and Port objects of the generated Java artifacts (after importing the WSDL) as method-local objects. Example : public class TestWS { ... private void testLocal() { wsdlImportedPackage.TargetService localService = new wsdlImportedPackage...

How to write more efficient code

Question of the century? I basically want to know which would be more efficient if I wrote this code as several different variables or if I used small arrays. int x = 34; int y = 28; int z = 293; vs double coordinate[3] = {34, 28, 293}; I have a coordinate struct which I will use in the following way: typedef struct coordinates_t ...

If I have three separate values that could all fit into 32 bits, does it make sense to use a uint to store them?

What I mean is, say I have a struct to represent some data and it looks like this: struct LilStruct { public readonly short A; public readonly byte B; public readonly byte C; public LilStruct(short a, byte b, byte c) { A = a; B = b; C = c; } } A short and two byte values could all fit i...

Most efficient way to read files in Java?

As most other people, I deal with file I/O a lot and I wanted to make sure that I wasn't losing time on reading the file. I currently know of FileReader() as the most efficient way to read files in Java, but I was hoping there would be something obscure that was better. Also, can you skip reading a line in a file in Java/C? ...

Linear Search Algorithm Optimization

I just finished a homework problem for Computer Science 1 (yes, it's homework, but hear me out!). Now, the assignment is 100% complete and working, so I don't need help on it. My question involves the efficiency of an algorithm I'm using (we aren't graded on algorithmic efficiency yet, I'm just really curious). The function I'm about to...

Comparing data bytewise in a effective way (with c++)

Question: Is there a more effective way to compare data bytewise than using the comparison operator of the c++ list container? I have to compare [large? 10kByte < size < 500kByte] amounts of data bytewise, to verify the integrity of external storage devices. Therefore I read files bytewise and store the values in a list of unsigned cha...