Examples of Timing


Examples of cc.mallet.util.Timing

    return avgEnergy - entropy;
  }

  public void computeMarginals (FactorGraph mdl)
  {
    Timing timing = new Timing ();

    this.mdl = mdl;
    rg = regioner.constructRegionGraph (mdl);
    RegionEdge[] pairs = chooseMessageSendingOrder ();

    newMessages = new MessageArray (rg);

    timing.tick ("GBP Region Graph construction");
   
    int iter = 0;
    do {

      oldMessages = newMessages;
      newMessages = oldMessages.duplicate ();
      sender.setMessageArray (oldMessages, newMessages);

      for (int i = 0; i < pairs.length; i++) {
        RegionEdge edge = pairs[i];
        sender.sendMessage (edge);
      }

      if (logger.isLoggable (Level.FINER)) {
        timing.tick ("GBP iteration "+iter);
      }

      iter++;

      if (useInertia)
View Full Code Here

Examples of com.bluesoft.util.metrics.core.Timing

    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );

    expect( mock.getCentile( eq( BigDecimal.valueOf( 95.0 ) ) ) )
            .andReturn( new TimingImpl( BigDecimal.valueOf( 1500000000L, 0 ), TimeUnit.NANOSECONDS ) );
    replay( mock );
    Timing timing = rounder.getCentile( BigDecimal.valueOf( 95.0 ) );
    assertEquals( timing.getUnit(), TimeUnit.MILLISECONDS );
    assertEquals( timing.getValue(), BigDecimal.valueOf( 1500000000000L, 9 ) );
    verify( mock );

    reset( mock );
    expect( mock.getCentile( eq( BigDecimal.valueOf( 95.0 ) ) ) )
            .andReturn( new TimingImpl( BigDecimal.valueOf( 1500000000L, 0 ), TimeUnit.MILLISECONDS ) );
    replay( mock );
    timing = rounder.getCentile( BigDecimal.valueOf( 95.0 ) );
    assertEquals( timing.getUnit(), TimeUnit.MILLISECONDS );
    assertEquals( timing.getValue(), BigDecimal.valueOf( 1500000000L, 0 ) );
    verify( mock );
  }
View Full Code Here

Examples of com.netflix.curator.test.Timing

    public int getServerPort() {
        return PORT;
    }

    public static IZkConnection createZkConnection(String connectString) {
        Timing                  timing = new Timing();
        CuratorFramework        client = CuratorFrameworkFactory.newClient(connectString, timing.session(), timing.connection(), new RetryOneTime(1));
        client.start();
        try
        {
            return new CuratorZKClientBridge(client);
        }
View Full Code Here

Examples of edu.stanford.nlp.util.Timing

  public void loadModelFile(String modelFile) {
    loadModelFile(modelFile, true);
  }

  private void loadModelFile(String modelFile, boolean verbose) {
    Timing t = new Timing();
    try {
      // System.err.println(Config.SEPARATOR);
      System.err.println("Loading depparse model file: " + modelFile + " ... ");
      String s;
      BufferedReader input = IOUtils.readerFromString(modelFile);

      int nDict, nPOS, nLabel;
      int eSize, hSize, nTokens, nPreComputed;
      nDict = nPOS = nLabel = eSize = hSize = nTokens = nPreComputed = 0;

      for (int k = 0; k < 7; ++k) {
        s = input.readLine();
        if (verbose) {
          System.err.println(s);
        }
        int number = Integer.parseInt(s.substring(s.indexOf('=') + 1));
        switch (k) {
          case 0:
            nDict = number;
            break;
          case 1:
            nPOS = number;
            break;
          case 2:
            nLabel = number;
            break;
          case 3:
            eSize = number;
            break;
          case 4:
            hSize = number;
            break;
          case 5:
            nTokens = number;
            break;
          case 6:
            nPreComputed = number;
            break;
          default:
            break;
        }
      }


      knownWords = new ArrayList<String>();
      knownPos = new ArrayList<String>();
      knownLabels = new ArrayList<String>();
      double[][] E = new double[nDict + nPOS + nLabel][eSize];
      String[] splits;
      int index = 0;

      for (int k = 0; k < nDict; ++k) {
        s = input.readLine();
        splits = s.split(" ");
        knownWords.add(splits[0]);
        for (int i = 0; i < eSize; ++i)
          E[index][i] = Double.parseDouble(splits[i + 1]);
        index = index + 1;
      }
      for (int k = 0; k < nPOS; ++k) {
        s = input.readLine();
        splits = s.split(" ");
        knownPos.add(splits[0]);
        for (int i = 0; i < eSize; ++i)
          E[index][i] = Double.parseDouble(splits[i + 1]);
        index = index + 1;
      }
      for (int k = 0; k < nLabel; ++k) {
        s = input.readLine();
        splits = s.split(" ");
        knownLabels.add(splits[0]);
        for (int i = 0; i < eSize; ++i)
          E[index][i] = Double.parseDouble(splits[i + 1]);
        index = index + 1;
      }
      generateIDs();

      double[][] W1 = new double[hSize][eSize * nTokens];
      for (int j = 0; j < W1[0].length; ++j) {
        s = input.readLine();
        splits = s.split(" ");
        for (int i = 0; i < W1.length; ++i)
          W1[i][j] = Double.parseDouble(splits[i]);
      }

      double[] b1 = new double[hSize];
      s = input.readLine();
      splits = s.split(" ");
      for (int i = 0; i < b1.length; ++i)
        b1[i] = Double.parseDouble(splits[i]);

      double[][] W2 = new double[nLabel * 2 - 1][hSize];
      for (int j = 0; j < W2[0].length; ++j) {
        s = input.readLine();
        splits = s.split(" ");
        for (int i = 0; i < W2.length; ++i)
          W2[i][j] = Double.parseDouble(splits[i]);
      }

      preComputed = new ArrayList<Integer>();
      while (preComputed.size() < nPreComputed) {
        s = input.readLine();
        splits = s.split(" ");
        for (String split : splits) {
          preComputed.add(Integer.parseInt(split));
        }
      }
      input.close();
      classifier = new Classifier(config, E, W1, b1, W2, preComputed);
    } catch (IOException e) {
      throw new RuntimeIOException(e);
    }

    // initialize the loaded parser
    initialize(verbose);
    t.done("Initializing dependency parser");
  }
View Full Code Here

Examples of music.ui.panels.Timing

    srPanel.add(panel);

    tabbedPane.addTab("Practice", practicePanel);
    tabbedPane.addTab("Sight Reading", srPanel);
    tabbedPane.addTab("Timing", timing = new Timing());

    setContentPane(mainPane);

    pack();
View Full Code Here

Examples of org.apache.curator.test.Timing

public class TestFrameworkEdges extends BaseClassForTests
{
    @Test
    public void connectionLossWithBackgroundTest() throws Exception
    {
        Timing timing = new Timing();
        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), 1, new RetryOneTime(1));
        try
        {
            final CountDownLatch latch = new CountDownLatch(1);
            client.start();
            client.getZookeeperClient().blockUntilConnectedOrTimedOut();
            server.close();
            client.getChildren().inBackground
            (
                new BackgroundCallback()
                {
                    public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
                    {
                        latch.countDown();
                    }
                }
            ).forPath("/");
            Assert.assertTrue(timing.awaitLatch(latch));
        }
        finally
        {
            client.close();
        }
View Full Code Here

Examples of org.apache.curator.test.Timing

    }

    @Test
    public void testReconnectAfterLoss() throws Exception
    {
        Timing timing = new Timing();
        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
        try
        {
            client.start();

            final CountDownLatch lostLatch = new CountDownLatch(1);
            ConnectionStateListener listener = new ConnectionStateListener()
            {
                @Override
                public void stateChanged(CuratorFramework client, ConnectionState newState)
                {
                    if ( newState == ConnectionState.LOST )
                    {
                        lostLatch.countDown();
                    }
                }
            };
            client.getConnectionStateListenable().addListener(listener);

            client.checkExists().forPath("/");

            server.close();

            Assert.assertTrue(timing.awaitLatch(lostLatch));

            try
            {
                client.checkExists().forPath("/");
                Assert.fail();
View Full Code Here

Examples of org.apache.curator.test.Timing

    }

    @Test
    public void testBackgroundFailure() throws Exception
    {
        Timing timing = new Timing();
        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
        client.start();
        try
        {
            final CountDownLatch latch = new CountDownLatch(1);
            client.getConnectionStateListenable().addListener
                (
                    new ConnectionStateListener()
                    {
                        @Override
                        public void stateChanged(CuratorFramework client, ConnectionState newState)
                        {
                            if ( newState == ConnectionState.LOST )
                            {
                                latch.countDown();
                            }
                        }
                    }
                );

            client.checkExists().forPath("/hey");
            client.checkExists().inBackground().forPath("/hey");

            server.stop();

            client.checkExists().inBackground().forPath("/hey");
            Assert.assertTrue(timing.awaitLatch(latch));
        }
        finally
        {
            Closeables.closeQuietly(client);
        }
View Full Code Here

Examples of org.apache.curator.test.Timing

public class TestFramework extends BaseClassForTests
{
    @Test
    public void     testConnectionState() throws Exception
    {
        Timing                  timing = new Timing();
        CuratorFramework        client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
        try
        {
            final BlockingQueue<ConnectionState>        queue = new LinkedBlockingQueue<ConnectionState>();
            ConnectionStateListener                     listener = new ConnectionStateListener()
            {
                @Override
                public void stateChanged(CuratorFramework client, ConnectionState newState)
                {
                    queue.add(newState);
                }
            };
            client.getConnectionStateListenable().addListener(listener);

            client.start();
            Assert.assertEquals(queue.poll(timing.multiple(4).seconds(), TimeUnit.SECONDS), ConnectionState.CONNECTED);
            server.stop();
            Assert.assertEquals(queue.poll(timing.multiple(4).seconds(), TimeUnit.SECONDS), ConnectionState.SUSPENDED);
            Assert.assertEquals(queue.poll(timing.multiple(4).seconds(), TimeUnit.SECONDS), ConnectionState.LOST);
        }
        finally
        {
            Closeables.closeQuietly(client);
        }
View Full Code Here

Examples of org.apache.curator.test.Timing

    }

    @Test
    public void     testCreateACLWithReset() throws Exception
    {
        Timing timing = new Timing();
        CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();
        CuratorFramework client = builder
            .connectString(server.getConnectString())
            .sessionTimeoutMs(timing.session())
            .connectionTimeoutMs(timing.connection())
            .authorization("digest", "me:pass".getBytes())
            .retryPolicy(new RetryOneTime(1))
            .build();
        client.start();
        try
        {
            final CountDownLatch lostLatch = new CountDownLatch(1);
            ConnectionStateListener listener = new ConnectionStateListener()
            {
                @Override
                public void stateChanged(CuratorFramework client, ConnectionState newState)
                {
                    if ( newState == ConnectionState.LOST )
                    {
                        lostLatch.countDown();
                    }
                }
            };
            client.getConnectionStateListenable().addListener(listener);

            ACL acl = new ACL(ZooDefs.Perms.WRITE, ZooDefs.Ids.AUTH_IDS);
            List<ACL> aclList = Lists.newArrayList(acl);
            client.create().withACL(aclList).forPath("/test", "test".getBytes());

            server.stop();
            Assert.assertTrue(timing.awaitLatch(lostLatch));
            try
            {
                client.checkExists().forPath("/");
                Assert.fail("Connection should be down");
            }
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.