Examples of DummyPojo


Examples of org.apache.directmemory.misc.DummyPojo

    @BenchmarkOptions( benchmarkRounds = 50000, warmupRounds = 0, concurrency = 1 )
    @Test
    public void basicBench()
    {

        DummyPojo d = new DummyPojo( "test-" + rnd.nextInt( 100000 ), 1024 + rnd.nextInt( 1024 ) );
        Cache.put( d.name, d );
        DummyPojo d2 = (DummyPojo) Cache.retrieve( d.name );

        assertEquals( d.name, d2.name );

    }
View Full Code Here

Examples of org.apache.directmemory.misc.DummyPojo

        throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        logger.info( "begin " + serializer.getClass().toString() );
        MonitorService stopWatch = Monitor.get( "serializer." + name + "." + size + "bytes" );
        MonitorService stopWatch2 = Monitor.get( "deserializer." + name + "." + size + "bytes" );
        DummyPojo pojo = new DummyPojo( "test", size );
        for ( int i = 0; i < howMany; i++ )
        {
            long split = stopWatch.start();
            final byte[] array = serializer.serialize( pojo );
            stopWatch.stop( split );
            long split2 = stopWatch2.start();
            DummyPojo check = (DummyPojo) serializer.deserialize( array, pojo.getClass() );
            stopWatch2.stop( split2 );
            assertNotNull( "object has not been serialized", check );
            assertEquals( pojo.name, check.name );
        }
        logger.info( "end serialize " + serializer.getClass().toString() + "\r\n" + stopWatch.toString() );
View Full Code Here

Examples of org.apache.directmemory.misc.DummyPojo

    @BenchmarkOptions( benchmarkRounds = 50000, warmupRounds = 0, concurrency = 1 )
    @Test
    public void basicBench()
    {

        DummyPojo d = new DummyPojo( "test-" + rnd.nextInt( 100000 ), 1024 + rnd.nextInt( 1024 ) );
        Cache.put( d.name, d );
        DummyPojo d2 = (DummyPojo) Cache.retrieve( d.name );

        assertEquals( d.name, d2.name );

    }
View Full Code Here

Examples of org.directmemory.misc.DummyPojo

 
  @BenchmarkOptions(benchmarkRounds = 50000, warmupRounds=0, concurrency=1)
  @Test
  public void basicBench() {
   
    DummyPojo d = new DummyPojo("test-" + rnd.nextInt(100000), 1024 + rnd.nextInt(1024));
    Cache.put(d.name, d);
    DummyPojo d2 = (DummyPojo) Cache.retrieve(d.name);
   
    assertEquals(d.name, d2.name);

  }
View Full Code Here

Examples of org.directmemory.misc.DummyPojo

  private static Logger logger=LoggerFactory.getLogger(SerializerTest.class);
  private void testSerializer(String name, Serializer serializer, int size, int howMany) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
    logger.info("begin " + serializer.getClass().toString());
        Monitor stopWatch = Monitor.get("serializer." + name + "." + size + "bytes");
        Monitor stopWatch2 = Monitor.get("deserializer." + name + "." + size + "bytes");
    DummyPojo pojo = new DummyPojo("test", size);
    for (int i = 0; i < howMany; i++) {
          long split = stopWatch.start();
      final byte[] array = serializer.serialize(pojo, pojo.getClass());
      stopWatch.stop(split);
      long split2 = stopWatch2.start();
      DummyPojo check = (DummyPojo) serializer.deserialize(array, pojo.getClass());
      stopWatch2.stop(split2);
      assertNotNull("object has not been serialized", check);
      assertEquals(pojo.name, check.name);
    }
    logger.info("end serialize " + serializer.getClass().toString() + "\r\n" + stopWatch.toString());
View Full Code Here

Examples of org.directmemory.misc.DummyPojo

        public void run() {
          int i = 0;
          try {
            int numOps = 100;
            while (++i < numOps) {
              DummyPojo pojo = new DummyPojo(getName() + "-" + i, 1024);
              cache.put(pojo.name, pojo);
//              DummyPojo otherPojo = (DummyPojo)cache.get(getName() + "-" + i);
//              if (otherPojo == null)
//                System.out.println("errore");;
              int pause = 10;
View Full Code Here

Examples of org.directmemory.misc.DummyPojo

        public void run() {
          int i = 0;
          try {
            int numOps = 100;
            while (++i < numOps) {
              @SuppressWarnings("unused")
              DummyPojo pojo = (DummyPojo)cache.get(getName() + "-" + i);
              int pause = 10;
              sleep(pause);
              }
          } catch (InterruptedException ex) {
View Full Code Here

Examples of org.directmemory.misc.DummyPojo

  }
 
  @Test
  public void addAndRetrieve() {
    CacheStore cache = new CacheStore(1, CacheStore.KB(4), 1);
    cache.put("test1", new DummyPojo("test1", fixedSize()));
    logger.debug("put test1 " + cache.toString());
    cache.put("test2", new DummyPojo("test2", fixedSize()));
    logger.debug("put test2 " + cache.toString());
    cache.put("test3", new DummyPojo("test3", fixedSize()));
    logger.debug("put test3 " + cache.toString());
    logger.debug("ask for test1 " + cache.toString());
    DummyPojo pojo1 = (DummyPojo)cache.get("test1");
    logger.debug("got test1 " + cache.toString());
    DummyPojo pojo2 = (DummyPojo)cache.get("test2");
    logger.debug("got test2 " + cache.toString());
    DummyPojo pojo3 = (DummyPojo)cache.get("test3");
    logger.debug("got test3 " + cache.toString());
    assertNotNull(pojo1);
    assertEquals("test1", pojo1.name);
    assertNotNull(pojo2);
    assertEquals("test2", pojo2.name);
View Full Code Here

Examples of org.directmemory.misc.DummyPojo

  @Test public void goOverTheLimitWithProtostuff() {
    int limit = 10;
    CacheStore store = new CacheStore(limit, 1 * 1024 * 1024, 1);
    store.serializer = new ProtoStuffSerializer();
    for (int i = 1; i <= limit * 2; i++) {
      DummyPojo pojo = new  DummyPojo("test" + 1, 1024);
      store.put("test" + i, pojo);
      if (i <= limit) {
        assertEquals(store.heapEntriesCount(), i);
      } else {
        assertEquals(limit, store.heapEntriesCount());
View Full Code Here

Examples of org.directmemory.misc.DummyPojo

  @Test public void goOverTheLimitPutAndGetWithProtostuff() {
    int limit = 1000;
    CacheStore cache = new CacheStore(limit, 10 * 1024 * 1024, 1);
    cache.serializer = new ProtoStuffSerializer();
    for (int i = 1; i <= limit * 1.5; i++) {
      DummyPojo pojo = new  DummyPojo("test" + i, 1024);
      cache.put("test" + i, pojo);
      if (i <= limit) {
        assertEquals(cache.heapEntriesCount(), i);
      } else {
        assertEquals(limit, cache.heapEntriesCount());
      }
    }

    logger.debug("goOverTheLimitPutAndGet " + cache.toString());
   
    for (int i = 1; i <= limit * 1.5; i++) {
      @SuppressWarnings("unused")
      DummyPojo pojo = new  DummyPojo("test" + i, 1024);
      @SuppressWarnings("unused")
      DummyPojo newPojo = (DummyPojo)cache.get("test" + i);
    }
   
    assertEquals(limit, cache.heapEntriesCount());
//    assertEquals(518500, cache.usedMemory());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.