Package org.jboss.dna.common.statistic

Examples of org.jboss.dna.common.statistic.Stopwatch


     *      org.jboss.dna.graph.request.Request)
     */
    public void execute( ExecutionContext context,
                         Request request ) throws RepositorySourceException {
        Logger logger = context.getLogger(getClass());
        Stopwatch sw = null;
        if (logger.isTraceEnabled()) {
            sw = new Stopwatch();
            sw.start();
        }
        // Do any commands update/write?
        RequestProcessor processor = new MapRequestProcessor(context, this.repository, this.source.getRepositoryContext());

        Lock lock = request.isReadOnly() ? repository.getLock().readLock() : repository.getLock().writeLock();
        lock.lock();
        try {
            // Obtain the lock and execute the commands ...
            processor.process(request);
        } finally {
            try {
                processor.close();
            } finally {
                lock.unlock();
            }
        }
        if (logger.isTraceEnabled()) {
            assert sw != null;
            sw.stop();
            logger.trace("MapRepositoryConnection.execute(...) took " + sw.getTotalDuration());
        }
    }
View Full Code Here


    public void beforeEach() {
        context = new ExecutionContext();
        typeSystem = context.getValueFactories().getTypeSystem();
        workspaceName1 = "cars";
        workspaceName2 = "aircraft";
        sw = new Stopwatch();

        sourceName = "source";
        source = new InMemoryRepositorySource();
        source.setName(sourceName);
        content = Graph.create(source, context);
View Full Code Here

            }

            // Perform second batch ...
            batch = graph.batch();
            totalNumberCreated += createChildren(batch, initialPath, "secondBranch", 2, numberOfPropertiesPerNode, 2, null);
            Stopwatch sw = new Stopwatch();
            sw.start();
            batch.execute();
            sw.stop();
            System.out.println("     final " + getTotalAndAverageDuration(sw, totalNumberCreated));
            assertThat(totalNumberCreated, is(totalNumber + calculateTotalNumberOfNodesInTree(2, 2, false)));
        }
        return (int)totalNumberCreated;
View Full Code Here

                   "dnaxml:target=" + target,
                   "dnaxml:processingInstructionContent=" + data);
    }

    protected void parse( String relativePathToXmlFile ) throws IOException, SAXException {
        Stopwatch sw = new Stopwatch();
        sw.start();
        InputStream stream = getClass().getClassLoader().getResourceAsStream(relativePathToXmlFile);
        try {
            XMLReader reader = XMLReaderFactory.createXMLReader();
            reader.setContentHandler(handler);
            reader.setErrorHandler(handler);
            // Ensure handler acting as entity resolver 2
            reader.setProperty(XmlSequencer.DECL_HANDLER_FEATURE, handler);
            // Ensure handler acting as lexical handler
            reader.setProperty(XmlSequencer.LEXICAL_HANDLER_FEATURE, handler);
            // Ensure handler acting as entity resolver 2
            XmlSequencer.setFeature(reader, XmlSequencer.ENTITY_RESOLVER_2_FEATURE, true);
            // Prevent loading of external DTDs
            XmlSequencer.setFeature(reader, XmlSequencer.LOAD_EXTERNAL_DTDS_FEATURE, false);
            // Prevent the resolving of DTD entities into fully-qualified URIS
            XmlSequencer.setFeature(reader, XmlSequencer.RESOLVE_DTD_URIS_FEATURE, false);
            reader.parse(new InputSource(stream));
        } finally {
            if (stream != null) stream.close();
            sw.stop();
            System.out.println("Parsing: " + sw);
        }
        pathsInCreationOrder = new LinkedList<Path>(output.getOrderOfCreation());
    }
View Full Code Here

        request.add(projectedRequest[2], false, false, projection[2]);
        request.freeze();
        assertThat(request.hasIncompleteRequests(), is(true));
        CountDownLatch latch = request.getLatch();
        assertThat(latch.getCount(), is(3L));
        Stopwatch sw = new Stopwatch();
        sw.start();
        new Thread(new CountDownRunnable(latch, 100L)).start();
        request.await(); // this blocks until the latch reaches 0
        assertThat(latch.getCount(), is(0L));
        sw.stop();
        assertThat(sw.getTotalDuration().getDurationInMilliseconds().intValue() >= 250, is(true));
    }
View Full Code Here

    public void shouldCreateDeepBranchUsingIndividualRequests() {
        String initialPath = "";
        int depth = 50;
        int numChildrenPerNode = 1;
        int numPropertiesPerNode = 7;
        Stopwatch sw = new Stopwatch();
        boolean batch = false;
        String description = "deep and narrow tree, 1x50";
        createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, description);
    }
View Full Code Here

    public void shouldCreateDeepBranchUsingOneBatch() {
        String initialPath = "";
        int depth = 50;
        int numChildrenPerNode = 1;
        int numPropertiesPerNode = 7;
        Stopwatch sw = new Stopwatch();
        boolean batch = true;
        String description = "deep and narrow tree, 1x50";
        createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, description);
    }
View Full Code Here

    public void shouldCreateFlatAndWideTreeUsingOneBatch() {
        String initialPath = "";
        int depth = 1;
        int numChildrenPerNode = 300;
        int numPropertiesPerNode = 7;
        Stopwatch sw = new Stopwatch();
        boolean batch = true;
        createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null);
    }
View Full Code Here

    public void shouldCreateBinaryTreeUsingOneBatch() {
        String initialPath = "";
        int depth = 8;
        int numChildrenPerNode = 2;
        int numPropertiesPerNode = 7;
        Stopwatch sw = new Stopwatch();
        boolean batch = true;
        String description = "binary tree, 2x8";
        createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, description);
    }
View Full Code Here

    public void shouldCreateTreeWith10ChildrenAnd2LevelsDeepUsingIndividualRequests() {
        String initialPath = "";
        int depth = 2;
        int numChildrenPerNode = 10;
        int numPropertiesPerNode = 7;
        Stopwatch sw = new Stopwatch();
        boolean batch = false;
        createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null);
    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.common.statistic.Stopwatch

Copyright © 2018 www.massapicom. 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.