1 package org.apache.lucene.benchmark.byTask.stats;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import java.util.ArrayList;
21 import java.util.List;
23 import org.apache.lucene.benchmark.byTask.tasks.PerfTask;
24 import org.apache.lucene.benchmark.byTask.utils.Config;
28 * Test run data points collected as the test proceeds.
32 // stat points ordered by their start time.
33 // for now we collect points as TaskStats objects.
34 // later might optimize to collect only native data.
35 private ArrayList<TaskStats> points = new ArrayList<TaskStats>();
37 private int nextTaskRunNum = 0;
39 private TaskStats currentStats;
42 * Create a Points statistics object.
44 public Points (Config config) {
48 * Return the current task stats.
49 * the actual task stats are returned, so caller should not modify this task stats.
50 * @return current {@link TaskStats}.
52 public List<TaskStats> taskStats () {
57 * Mark that a task is starting.
58 * Create a task stats for it and store it as a point.
59 * @param task the starting task.
60 * @return the new task stats created for the starting task.
62 public synchronized TaskStats markTaskStart (PerfTask task, int round) {
63 TaskStats stats = new TaskStats(task, nextTaskRunNum(), round);
64 this.currentStats = stats;
69 public TaskStats getCurrentStats() {
73 // return next task num
74 private synchronized int nextTaskRunNum() {
75 return nextTaskRunNum++;
79 * mark the end of a task
81 public synchronized void markTaskEnd (TaskStats stats, int count) {
82 int numParallelTasks = nextTaskRunNum - 1 - stats.getTaskRunNum();
83 // note: if the stats were cleared, might be that this stats object is
84 // no longer in points, but this is just ok.
85 stats.markEnd(numParallelTasks, count);
89 * Clear all data, prepare for more tests.
91 public void clearData() {