Bookmark Topic Watch Topic
  • New Topic

costing  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
How much does a program cost in terms of time? If we wanted to analyze the cost of a program, we have to figure out the cost each and every statement made in the application program. In your data structure and algorithms courses, you have to analyze the performance of algorithms to know how to construct efficient programs. In there, the main driving factor is the number of multiplications in an algorithm for example. Here, we have to analyze the cost of selecting one program over the other.

Consider the following algorithm to calculate the cost of a program.

The program is prepared to be opened as a file to be modified
Before and after every statement, put statements that read the time in milliseconds
Calculate the cost of the statement by subtracting the times off of each other
Output gathered statistics to application developer

Now, how can we do this with style? Using the JTextArea, we can output three columns as follows: line number �\t� cost in milliseconds �\t� the Java statement; and the last row should output some global statistics. The application developer can then determine the statements that take intensive CPU cycles and begin to consider alternative coding approaches.
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
"aaaaa aaaaa"
Please don't post the same message in multiple forums. It makes a conversation difficult to follow.

Also, please adjust your display name to match the Naming Policy (basically it should be a legit first and last name).

Lastly -- I'm moving this to the Performance forum, where I think this is a better fit. Please post your replies here.

Thanks! And welcome to the JavaRanch!
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!