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

Performance Test Code

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
}


 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Performance? What way? Speed? Memory usage? CPU usage?
 
Nilesh Raje
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not post the same question multiple times. Let's continue the discussion in this duplicate thread.
 
    Bookmark Topic Watch Topic
  • New Topic