efficiency

Can I compare IL code to determine which technique is faster or better?

Background This question got me thinking about something. Lately, since I've been looking at linq pad's IL functionality, I've been comparing the IL code of two approaches to the same problem to "determine" which is best. Using the question linked to above, about converting an array, I generated the IL code for the two answers: var a...

Increasing Speed

A broad question I know but: Does anyone have general tips on increasing execution speed in Fortran programs? ...

Most efficient way to find the closest integer in MySQL?

I have a table in a MySQL database from which I want to select the row with the closest timestamp to another given timestamp. time is the timestamp column (an integer UNIX timestamp). I chose 1250710000 arbitrarily. This is the query that I've come up with, and I'm wondering if there's a more efficient way to do it: SELECT *, ABS(time...

How to sort an array containing class objects by a property value of a class instance?

Possible Duplicate: How to sort an array of object by a specific field in C#? Given the following code: MyClass myClass; MyClassArray[] myClassArray = new MyClassArray[10]; for(int i; i < 10; i++;) { myClassArray[i] = new myClass(); myClassArray[i].Name = GenerateRandomName(); } The end result could for example look ...

Deleting objects from an ArrayList in Java

Hi guys, I have a big doubt and I hope someone can help me out. I need to delete some objects from an arraylist if they meet a condition and I'm wondering which way could be more efficient. Here's the situation: I have a class that contains an arraylist containing some other objects. I have to iterate over this arraylist and delete all ...

Becoming the most efficient one-man team

Like many here, I am a one-man development team. I'm responsible for everything from gathering project requirements, designing concept-screens, planning and developing databases, and writing all code. Being a one-man team is nice, but has its negatives. I don't have the ability to quickly consult with other developers, I rarely get a se...

Time Complexity O() of isPalindrome()

I have this method isPalindrome() and am trying to find the time complexity of it, and also rewrite the code more efficiently. boolean isPalindrome(String s) { boolean bP = true; for(int i=0; i<s.length(); i++) { if(s.charAt(i) != s.charAt(s.length()-i-1)) { bP = false; } } return bP; } Now I know this code...

Which is preferable; declaring & setting variable & calling twice, or calculating value on-the-fly twice?

Which is the most efficient way to do this? Sub pvaSetWeek(Optional weekOffset As Long = 0) Dim theDayToday As Long theDayToday = Weekday(Now, vbMonday) 'Set start to Monday Range("pvaStartDate") = Int(Now) - (theDayToday - 1) - (weekOffset * 7) 'Set end to Sunday Range("pvaEndDate") = Int(Now) + (7 - theDayTo...

Python string 'join' is faster(?) than '+', but what's wrong here?

I asked the most efficient method for mass dynamic string concatenation in an earlier post and I was suggested to use the join method, the best, simplest and fastest method to do so (as everyone said that). But while I was playing with string concatenations, I found some weird(?) results. I'm sure something is going on but I can't not ge...

Describing PHP functions efficiently

How can you describe the parameters and return type (getter/setter) of your PHP functions? I need to tell my moderator the return type and list the parameters for each function. I have hundreds of functions so this is becoming problem, since I need to do this for every single revision. I use at the moment the following procedure ack-...

Should I optimise my python code like C++? Does it matter?

I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++. Things like: In an if statement with an or always put the condition most likely to ...

What IDE features should I learn to use

I'm a largely self-taught front-end developer only just making the transition into back-end development in order to be able to say yes to more projects. I've found eclipse to be my favourite text editor for javascript and php, but I'm conscious that it (and other IDEs) have a whole load of features which I don't know how to use, or why ...

PHP: What's the mathematically efficient way to find a 'subgrid' of a larger grid?

Hi, i'm trying to find an efficient way to find a subportion of a large grid. Currently I'm looping through rows to define a FROM-TO selection of ids in that row, but this doesn't feel right... Let's say I have a grid of 200x200 fields (x between 1 and 200, y between 1 and 200). Every field also has it's unique ID, starting at X1,Y1 (f...

Being a better / more efficient PLC Programmer

Hello guys! The company I am doing my intership/appretinceship in, does mainly PLC programming with Siemens modules. Comes from the fact that most of the people were electric guys and switched over to engineering. My problem as newbie there is, that I can't be really efficient and fast when I code PLC software. Even though I am very e...

Efficient way to use python's lambda, map

I need to store a big list of integers in Bigtable(db). For efficiency I am storing them as diff between 2 consecutive items. for eg: original_list = [1005, 1004, 1003, 1004, 1006] Storing the above list(which actually contains more than 1000k items) as start = 1005 diff = [-1, -1, 1, 2] The closest I could manage is, ltp = [st...

Split a list of dates by another list of dates

I have a number of nodes in a network. The nodes send status information every hour to indicate that they are alive. So i have a list of Nodes and the time when they were last alive. I want to graph the number of alive nodes over the time. The list of nodes is sorted by the time they were last alive but i cant figure out a nice way to c...

Documenting components effectively by Doxygen

How can you document components of your code such as the following effectively when the source codes of the components are in different locations? Example of my components in my first database project homepage - user_bar, check_login_status ask_question - form_ask_question login - form_login question_id - (form_login), form...

How to quickly find maximal element of a sum of vectors?

I have a following code in a most inner loop of my program struct V { float val [200]; // 0 <= val[i] <= 1 }; V a[600]; V b[250]; V c[250]; V d[350]; V e[350]; // ... init values in a,b,c,d,e ... int findmax(int ai, int bi, int ci, int di, int ei) { float best_val = 0.0; int best_ii = -1; for (int ii = 0; ii < 200; ii++) { ...

In C#, When is a reference type more efficient than a value type ?

Is there any time in which a reference type is more efficient than a value type ? Why ? Can you give an example ? ...

Research question on programming language and writing software.

I am looking for research papers, case scenarios etc that explain or show why less code is easier to maintain, debug, etc. Possibly how choice of programming language can affect it etc. I have no idea how to find this information. Googling something like "research programming less code" yield tons of results and the first few pages doesn...