Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Too many columns slowing down program

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two questions. I'll start by posting my code:


First of all, in my main loop, I'm going to have to access all of my JTextFields. I wanted to put the buildGUI function seperate from the main loop which is good programming practice, but I would have to make all of the TextFields global, which is bad programming practice. Should I leave it like it is or is there a solution to this problem?

Secondly, the program runs fine the way it is now, but if I add a few more columns its starts to lag horribly... What is causing this lag and how do I fix it?
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see a break statement for the outer loop.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally, it is impossible (or at least VERY HARD) to find where the slowdown is by looking at the code. It's almost NEVER where you think it would be. The best way to find it is to get some kind of profiler that will show you where your code is spending all it's time. Then you can focus on that part.
 
Gulshan Singh
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the fact that the outer loop doesn't break can't be the problem. Even if I have four columns, the code in the loop where the program is spending its time is the same. If I have 8 columns, the code in the loop is still the same. So it doesn't make sense that it's getting slower when its looping through the same code in both situations... any ideas?
 
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say it would definitely slow down your application. Your program will constantly be executing the loop. Although it may not execute any code, it will still check, and check, and check, and check, and check... In other words, your CPU will be very very busy.
 
Gulshan Singh
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But what I'm saying is, even though it checks and checks and checks, the number of checks is going to be the same no matter how many columns there are, because its only checking for one column during the loop. I'll change it so its more efficient in general, but I'm going to guess that the problem with the columns will still apply. I'll post back when I make the changes.
 
Marshal
Posts: 28271
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gulshan Singh wrote:I'll post back when I make the changes.



I would suggest you need a selection listener on your table, so you only do that code when the selected row changes.
 
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic