@Test public void performance() { int COUNT = 10000; Set<Revision> revisions = Sets.newHashSetWithExpectedSize(COUNT); SimpleVersionGraph versionGraph = SimpleVersionGraph.init(); Revision prev = null; for (int i=0; i<COUNT;i++) { SimpleVersion.Builder versionBuilder = new SimpleVersion.Builder() .changeset(mapOf("key", Integer.toString(i))); if (prev != null) { versionBuilder.parents(prev); } versionGraph = versionGraph.commit(versionBuilder.build()); prev = versionGraph.getTip().getRevision(); revisions.add(prev); } System.out.println("begin " + COUNT); long time, ts = System.currentTimeMillis(); SimpleVersionGraph optimizedGraph = versionGraph.optimize(versionGraph.getTip().revision).getGraph(); time = System.currentTimeMillis() - ts; System.out.println("keep tip only: " + time); assertThat(optimizedGraph.getTip().getProperties()).isEqualTo(mapOf("key", Integer.toString(COUNT - 1))); assertThat(Lists.newArrayList(optimizedGraph.getVersionNodes())).hasSize(1); ts = System.currentTimeMillis(); optimizedGraph = versionGraph.optimize(revisions).getGraph(); time = System.currentTimeMillis() - ts; System.out.println("keep all revisions: " + time); assertThat(optimizedGraph.getTip().getProperties()).isEqualTo(mapOf("key", Integer.toString(COUNT - 1))); assertThat(Lists.newArrayList(optimizedGraph.getVersionNodes())).hasSize(COUNT); System.out.flush(); }
public G getGraph() { return graph; }
OptimizedGraph { public G getGraph() { return graph; } }
OptimizedGraph { public G getGraph() { return graph; } OptimizedGraph(G graph, List<Revision> keptRevisions, List<Revision> squashedRevisions); }
OptimizedGraph { public G getGraph() { return graph; } OptimizedGraph(G graph, List<Revision> keptRevisions, List<Revision> squashedRevisions); G getGraph(); List<Revision> getSquashedRevisions(); List<Revision> getKeptRevisions(); }
OptimizedGraph { public G getGraph() { return graph; } OptimizedGraph(G graph, List<Revision> keptRevisions, List<Revision> squashedRevisions); G getGraph(); List<Revision> getSquashedRevisions(); List<Revision> getKeptRevisions();  }