Mercurial > hg > blitz_stable
view examples/entrysizer/TestSizer.java @ 18:4580bb12db30
Separate command execution from command logging.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sun, 05 Jul 2009 16:26:25 +0100 |
parents | 3dc0c5604566 |
children |
line wrap: on
line source
package entrysizer; import net.jini.core.entry.Entry; import org.dancres.blitz.mangler.EntrySizer; /** This class demonstrates how to use the Blitz EntrySizer which can be used to give an approximate size for an Entry once it's marshalled and ready for storage in the Blitz backend. This is useful for sizing heap, caches and disk storage (for a persistent or time-barrier-persistent Blitz). */ public class TestSizer { public static void main(String args[]) { try { /* Create an EntrySizer instance (EntrySizer is stateless) */ EntrySizer mySizer = new EntrySizer(); /* Create some example Entry's */ Entry[] myEntrys = new Entry[] {new DummyEntry("a"), new DummyEntry("abcdefgh"), new DummyEntry(null)}; /* For each example, get a size estimate from the Sizer. */ for (int i = 0; i < myEntrys.length; i++) { System.out.println("Size of: " + myEntrys[i] + " = " + mySizer.computeSize(myEntrys[i])); } } catch (Exception anE) { System.err.println("Whoops, didn't work"); anE.printStackTrace(System.err); } } }