JMH: Using the same static object in all Benchmark tests
问题 I have a class that constructs some complicated data (imagine a large XML or JSON structure - that sort of thing). Constructing it takes time. So I want to construct it once, and then use that same data in all tests. Currently I basically have a public static object instance defined in a class that defines main , and then refer to it explicitly in the tests (code is a very simplified example): public class Data { // This class constructs some complicated data } public class TestSet { public