optimization

How to see time taken by each method in Java program during execution

試著忘記壹切 提交于 2020-01-01 19:26:48
问题 I am trying to find the time taken by each method that my Java program calls, while executing. I do not want to litter my code with System.currentTimeMillis() . Maybe, something like a profiler or an IDE plugin, but I am not sure if that is what it is called. Can someone help me by pointing me in the right direction? Sample code : public static void main(String[] args){ Obj A = new Obj(); ObjDiff B = new ObjDiff(); A.callMe(); B.callMeToo(); } Tools/Frameworks : Eclipse Struts What I Want :

Fastest & I/O efficient way to combine heterogeneous CSV files in Python

不打扰是莪最后的温柔 提交于 2020-01-01 18:58:23
问题 Given ten 1MB csv files, each with slightly different layouts, I need to combine them into a normalized single file with the same header. Empty string is fine for nulls. Examples of columns: 1. FIELD1, FIELD2, FIELD3 2. FIELD2, FIELD1, FIELD3 3. FIELD1, FIELD3, FIELD4 4. FIELD3, FIELD4, FIELD5, FIELD6 5. FIELD2 The output would look like (although order not important, my code puts them in order discovered): FIELD1, FIELD2, FIELD3, FIELD4, FIELD5, FIELD6 So basically the fields can come in any

Fake-scrolling containers with very many controls

微笑、不失礼 提交于 2020-01-01 18:51:11
问题 I'm trying to optimize populating and scrolling a FlowLayoutPanel, but I've had issues with similar controls before, where if they have too many controls inside, it takes a really long while for the container to populate and get ready for use (and the scroller gets shorter and shorter, you might be familiar with that). I've read that you can use a pool of just the controls within visible boundaries of the container rectangle and simulate scrolling by repopulating them with corresponding

Finding the intersection of two arrays in Javascript [duplicate]

核能气质少年 提交于 2020-01-01 17:28:12
问题 This question already has answers here : Simplest code for array intersection in javascript (47 answers) Closed 4 years ago . This was an Amazon interview question I had an my answer was function intersection ( A , B ) { var C = []; for ( var a in A ) if ( B.indexOf(a) != -1 ) C.push(a); return C; } and he asked what the order of complexity was and I said, and I quote exactly, O(m * n) where m=A.length and n=B.length and he was saying there's a better way to do it and I was like WTF??????? He

Create method inside function

穿精又带淫゛_ 提交于 2020-01-01 17:07:11
问题 I am trying to create method inside a function. I can make this such a way: function sample() {}; sample.show = function() { alert() }; And I'll see the alert calling sample.show(); . But for the reason of code beautifying I want to move all method declarations inside functions. I tried that: function sample() { sample.show = function() { alert() }; } But I get: TypeError: Object function sample() has no method 'show' Another ways I tried: function sample() { this.show = function() { alert()

Optimising strategies for web app development

半城伤御伤魂 提交于 2020-01-01 16:52:10
问题 Many web apps out there these days are using APIs or code that they've not worked with themselves, and quite often are using it inefficiently. Some google maps mashups come to mind. With php/asp backends, HTML, javascript (especially with all the AJAX these days) - there are so many potential bottlenecks, problems, inefficiencies and double-ups. What strategies can you suggest to investigating, identifying and resolving slow-downs, redundant code, leaks and other issues in web-apps - both

Is it possible to update post meta from array in one call?

这一生的挚爱 提交于 2020-01-01 16:34:19
问题 Code snippet: $save_dbarray = array( 'email' => 'email@email.se', 'adress' => 'adress' ); //Save values from created array into db foreach($save_dbarray as $meta_key=>$meta_value) { update_post_meta($post_id, $meta_key, $meta_value); } Is there any way to optimize above code? In this simple scenario, it wouldn't matter, but If I have a large array then I guess it might be performance issues when updating? I would like to do something like: update_post_meta($post_id, $save_dbarray); Is this

3D Connected Points Labeling based on Euclidean distances

流过昼夜 提交于 2020-01-01 16:33:12
问题 Currently, I am working on a project that is trying to group 3d points from a dataset by specifying connectivity as a minimum euclidean distance. My algorithm right now is simply a 3d adaptation of the naive flood fill. size_t PointSegmenter::growRegion(size_t & seed, size_t segNumber) { size_t numPointsLabeled = 0; //alias for points to avoid retyping vector<Point3d> & points = _img.points; deque<size_t> ptQueue; ptQueue.push_back(seed); points[seed].setLabel(segNumber); while (!ptQueue

WCF - Overhead of throwing FaultExceptions within your service

六月ゝ 毕业季﹏ 提交于 2020-01-01 15:53:34
问题 I posted a question about using Messages versus Fault Exceptions to communicate business rules between services. I was under the impression it carried overhead to throw this exception over the wire, but considering it's just a message that get serialized and deserialized, they were in fact one and the same. But this got me thinking about throwing exceptions in general or more specifically throwing FaultExceptions. Now within my service, if i use throw new FaultException to communicate a

WCF - Overhead of throwing FaultExceptions within your service

浪尽此生 提交于 2020-01-01 15:53:31
问题 I posted a question about using Messages versus Fault Exceptions to communicate business rules between services. I was under the impression it carried overhead to throw this exception over the wire, but considering it's just a message that get serialized and deserialized, they were in fact one and the same. But this got me thinking about throwing exceptions in general or more specifically throwing FaultExceptions. Now within my service, if i use throw new FaultException to communicate a