1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.tests.performance.read;
14 import java.util.UUID;
16 import org.simantics.databoard.Bindings;
17 import org.simantics.datatypes.utils.LogUtils;
18 import org.simantics.db.Resource;
19 import org.simantics.db.Session;
20 import org.simantics.db.WriteGraph;
21 import org.simantics.db.common.request.WriteResultRequest;
22 import org.simantics.db.exception.DatabaseException;
23 import org.simantics.db.service.VirtualGraphSupport;
24 import org.simantics.db.testing.base.ExistingDatabaseTest;
27 public class LogTest extends ExistingDatabaseTest {
29 public static final int NODE_SIZE = 2;
30 public static final int TEN = 10;
31 public static final int THOUSAND = 1000;
32 public static final int MILLION = 1000000;
34 public static final int KEY_SIZE = TEN * 1000;
36 public void test() throws Exception {
38 Session session = getSession();
40 VirtualGraphSupport vgss = session.getService(VirtualGraphSupport.class);
42 long start = System.nanoTime();
44 session.sync(new WriteResultRequest<Resource>(vgss.getMemoryPersistent(UUID.randomUUID().toString())) {
47 public Resource perform(WriteGraph graph) throws DatabaseException {
49 LogUtils lu = new LogUtils(graph);
50 Resource log = lu.create(graph, NODE_SIZE, 0);
51 for(int i=0;i<KEY_SIZE;i++) {
52 Resource value = graph.newResource();
53 graph.claim(value, L0.InstanceOf, null, L0.String);
54 graph.claimValue(value, "Value" + i, Bindings.STRING);
55 lu.insert(graph, log, i, value);
63 long duration = System.nanoTime()-start;
64 System.err.println("WRITE at " + 1e-9*duration + "s.");