Bookmark Topic Watch Topic
  • New Topic

Performance Test Code  RSS feed

 
Nilesh Raje
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Report post to moderator
How to write a code to test the performance of class. For example I have these 2 class . Can any one give me example for this.?

---------------------------------------------

public class SlowDictionary {
private final Map<String, String> dict = new HashMap<String, String>();

public synchronized String translate(String word)
throws IllegalArgumentException {
if (!dict.containsKey(word)) {
throw new IllegalArgumentException(word + " not found.");
}
return dict.get(word);
}

public synchronized void addToDictionary(String word, String translation)
throws IllegalArgumentException {
if (dict.containsKey(word)) {
throw new IllegalArgumentException(word + " already exists.");
}
dict.put(word, translation);
}

public synchronized Set<String> getAllWords() {
return dict.keySet();
}
}

------------------------------------------------------------------------
public class WhatDoIDo{
private X x;
private boolean b;
private Object o;

public WhatDoIDo(X x) {
this.x = x;
}
synchronized Object z() {
if (!b) {
o = x.y();
b = true;
}
return o;
}
public interface X {
Object y();
}
}


 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Performance? What way? Speed? Memory usage? CPU usage?
 
Nilesh Raje
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Report post to moderator
Maneesh Godbole wrote:Performance? What way? Speed? Memory usage? CPU usage?


Hi ,

I belive all 3 ways..!

I would like to understand step by step. Can you just tell me each step by step.? Thanks a ton.

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question multiple times. Let's continue the discussion in this duplicate thread.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!