So I have this UltraCompoEditor that takes very long to load, and the ammount of rows inside it is very large. Anyways I'm a complete beginer with Infragistics (I'm an intern) and my VB is iffy at best. Anyways I was hoping that someone here might be able to give me some suggestions or point me in the right direction on how to speed this up. This application was created and has been mainted by interns, I belive I am the 5th one, so the code is'nt great.
Thank you for any help.
Hey I've been working my way through making my first app, and I've hit the first problem that I don't even know how to begin fixing.
I am making a SpriteKit game, and as I've been coding, performance has been slowly dropping. Clearly I am not handling lag well at all. (~20-30 fps on device)
The thing is though, I'm not sure how to tackle this issue. I am going through and trying to loosen the load on each frame, but..
Are there any methods of lag handling that most people use?
I tried setting up a timer system, so that I know how much each segment of code takes to run, but the data wasn't too helpful.
It doesn't even look like a specific segment of code is taking that long at all.
This is kind of a broad question I guess, but how should you go about lag handling in SpriteKit?
I have been looking at the speed of my software trying to fine a line here and there that I can speed up. I do NOT need help with general optimisation. I have found a specific line of background unmanaged code that seems to be taking a very long time, even when the amount of calls are considered. This is the line:
system.windows.forms.unsafenativemethods.getwindowtext(handleRef hWnd, StringBuilder lpstring, int nMaxCount)
Does anyone know:
how to speed it up/bypass it if it's not useful/replace it with
something better.
specifically where I would have written something in my code that causes this to be called - the more example the better on this one!
I've found some related topics on Google. But each of these relate to
a specific issue such as an error occurring when a one thread asks
another thread for something and the other thread has become detached.
This Link is helpful, but I can't quiet get my head around it.
Any and all help will be appreciated.
Thanks!
It sounds like you're using Control.Text a lot - this seems like the most likely caller of GetWindowText.
If you're updating your UI with the results of your simulation every time the simulation makes progress, you may well be able to improve the performance significantly just by rate-limiting the updates (e.g. just update 5 times per second).
I'm doing a presentation which much of it involves me coding with a keyboard I was hoping in order for clarity and to reduce potential error, it could be possible not have to retype some complex sections but have them 'typed' for me at a readable speed so that I can still talk over when it is being outputted.
Looking at intellij's macro it would work perfect except it run too fast for me to talk over, is there any other tools that you know of that could assist in this?
Thanks,
Ian.
Some people create ad-hoc live templates for their presentation that insert the whole code snippets for them. It's not human speed though.
You could try to create a small plugin with a single action which does Thread.sleep(...) synchronously and invoke it in your macros to slow them down. It's a bit tedious though.
You can split your live templates or macros in small chunks and comment after invoking each of them. This should add some continuity to the presentation and not let your listeners lose the focus.
In may Daily Job i come across this Dilemma :
"Stable System Vs Better Design"
In routine job when i am fixing some module, When i see bad design
-> Badly written code
-> Badly Written Algorithm
-> Optimization possible
I would prefer to fix these also along with issue i am fixing
But many people opposes my changes a few supports, People who opposes will say
"You should be business oriented if system is stable, If you change some thing may cause regression, Hence do not favor business"
some time :
you will see your own written code after 6 months, Always you will see some improvment opportunity in this
While who support will say:
This is continual improvement and system will be more stable
So i would like to know what you people think
If applicable, write a unit test (or several, to cover edge cases). This gives you the confidence to refactor and know that you haven't broken anything.
Of course, if the code is tightly coupled (or spaghetti!), that's going to be a problem.
If it ain't broken don't fix it - wrap it. Isolate the modules as much as you can without changing its implementation; they should be touched (fixed, improved) when / if a real need arises.
My opinion would be not to fix the old code if it looks not perfect unless the way it is written is interfering with your current task at hand.
Most of the code is written badly. It is a matter of fact. If you're not in a perfect team with the perfect understanding of quality value and the agreement on the approach to achieve and keep this quality level, your optimizations will not change the big picture. You may fix something now but the next guy will make the mess of the things again.
I have came to the conclusion that in this industry if its not broken, don't fix it unless there is a damn good reason to.
If you know the application inside out, or have comprehensive unit tests and time to test the application in a non-productive environment, go for it. Otherwise, do it just when it's necessary.
Both are correct and there is no easy way out.
If you don't fix problems as you encounter them, not all problems will be fixed.
If you break something with a fix that is not 100% related to the issue you're currently working on, then people will hate you.
On the other hand, if you fix some innocent code (or rather code that looks innocent) and it breaks in unexpected ways, you've found something valuable: Brittle code. Brittle code is usually something that no one dares to touch. But to make your product more stable, you must get rid of such code. The first step on this road is to find it.
I have to admit that such fixes cause a lot of "unnecessary" friction in the team. People will yell at you when you touch brittle code because they are afraid. Often, this code will blow into the face of your customers, so you will get heat from all kinds of directions.
So it really depends on how much pain you want to cause and what you're willing to endure. If you fix everything as you encounter it, the code will be better by the end of the year. But it often is worse by the end of the day.
I want to second all the "if it ain't broke, don't fix it" answers, but with a relevant link...
Things You Should Never Do, Part 1 - Joel Spolsky
In essence - sometimes that incomprehensible code is actually a necessary bugfix that you have no chance to understand.
On the one hand, changing code that's already more-or-less working can run the risk of breaking things, and it can easily become an all-consuming task.
On the other hand, leaving bad code alone for fear of breaking things can stifle new development, due to the burden of maintaining bad code.
Sometimes code looks bad because it has to deal with complicated corner cases, as Joel Spolsky points out, and rewriting it will create bugs by failing to cover those corner cases. Sometimes code looks bad because it really is bad, and rewriting it can fix bugs that you didn't even know were there. Experience with your code base should help you determine which code is which.
In Boy Scout Check-Ins, Jeff Moser discusses the idea of "always leaving the campground cleaner than you found it." Always leave the codebase cleaner than you found it, even if you can't fix everything; those little improvements add up over time.
As was said in this answer, unit tests are a good thing. Working Effectively with Legacy Code, by Michael Feathers, is a great resource on this topic.
I personally have a tendency to spend time fixing stuff rather than getting on with the required task. Unfortunately it is all too easy to start fixing what looks like an easy problem and unravelling a huge mess that you then wish you hadn't.
I have also worked with people who are the other way round, and can live with the bad bits as long as it gets the job done.
More often than not, you can spend ages 'getting something right' to make it easier to work with in the future and you'll find that code is never reused in the future.
I think the main thing is to have a balance of views on your team, discuss things regularly with others and ultimately, meet the requirements for your project, since it's the customer paying the bills.
Be constructive about any problems you find - don't just pick holes for the sake of it! Team code reviews help improve bad code over time as poor coders will start to understand how to make good code.
I would advise marking bad code with 'TODO' comments and then coming back to fix it later time/budget allows. At least you've got a flag for potential problem areas then, without having to (possibly) waste time on a fix that's not required there and then.