pax_global_header00006660000000000000000000000064144627145010014516gustar00rootroot0000000000000052 comment=2effa2c8310e1d3ad03c8ee02024edca9252b46a jmh-1.37/000077500000000000000000000000001446271450100122265ustar00rootroot00000000000000jmh-1.37/.github/000077500000000000000000000000001446271450100135665ustar00rootroot00000000000000jmh-1.37/.github/workflows/000077500000000000000000000000001446271450100156235ustar00rootroot00000000000000jmh-1.37/.github/workflows/pre-integration.yml000066400000000000000000000051361446271450100214620ustar00rootroot00000000000000name: JMH Pre-Integration Tests on: push: branches-ignore: - master - pr/* workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: test: runs-on: ${{ matrix.os }} strategy: matrix: java: [8, 11, 17, 20, 21-ea] os: [ubuntu-22.04, windows-2022, macos-11] profile: [default, reflection, asm, executor-virtual, executor-fjp, executor-custom] fail-fast: false name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}, ${{ matrix.profile }} timeout-minutes: 60 steps: - uses: actions/checkout@v3 - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v3 with: distribution: temurin java-version: ${{ matrix.java }} cache: maven check-latest: true - name: Set up perf (Linux) run: | sudo apt-get update sudo apt-get install -y linux-tools-common linux-tools-generic linux-tools-`uname -r` echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid perf stat echo 1 if: (runner.os == 'Linux') - name: Run build with tests (Default) run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml if: (matrix.profile == 'default') - name: Run build with tests (Reflection) run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml if: (runner.os == 'Linux') && (matrix.profile == 'reflection') - name: Run build without tests (Reflection) run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml -DskipTests if: (runner.os != 'Linux') && (matrix.profile == 'reflection') - name: Run build with tests (ASM) run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml if: (runner.os == 'Linux') && (matrix.profile == 'asm') - name: Run build without tests (ASM) run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml -DskipTests if: (runner.os != 'Linux') && (matrix.profile == 'asm') - name: Run build with tests (FJP Executor) run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml if: (runner.os == 'Linux') && (matrix.profile == 'executor-fjp') - name: Run build with tests (Custom Executor) run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml if: (runner.os == 'Linux') && (matrix.profile == 'executor-custom') - name: Run build with tests (Virtual Executor) run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml if: (runner.os == 'Linux') && (matrix.java == '21-ea') && (matrix.profile == 'executor-virtual') jmh-1.37/.gitignore000066400000000000000000000000251446271450100142130ustar00rootroot00000000000000*.iml target/ .idea/ jmh-1.37/.jcheck/000077500000000000000000000000001446271450100135335ustar00rootroot00000000000000jmh-1.37/.jcheck/conf000066400000000000000000000025401446271450100144040ustar00rootroot00000000000000; ; Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. ; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ; ; This code is free software; you can redistribute it and/or modify it ; under the terms of the GNU General Public License version 2 only, as ; published by the Free Software Foundation. ; ; This code is distributed in the hope that it will be useful, but WITHOUT ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ; version 2 for more details (a copy is included in the LICENSE file that ; accompanied this code). ; ; You should have received a copy of the GNU General Public License version ; 2 along with this work; if not, write to the Free Software Foundation, ; Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ; ; Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ; or visit www.oracle.com if you need additional information or have any ; questions. ; [general] project=code-tools repository=jmh jbs=codetools [checks] error=author,committer,reviewers,executable,symlink,whitespace [census] version=0 domain=openjdk.org [checks "whitespace"] files=.*\.cpp|.*\.hpp|.*\.c|.*\.h|.*\.java|.*\.cc|.*\.hh|.*\.m|.*\.mm [checks "reviewers"] committers=1 ignore=duke [checks "committer"] role=committer jmh-1.37/LICENSE000066400000000000000000000455121446271450100132420ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/README.md000066400000000000000000000201361446271450100135070ustar00rootroot00000000000000# Java Microbenchmark Harness (JMH) JMH is a Java harness for building, running, and analysing nano/micro/milli/macro benchmarks written in Java and other languages targeting the JVM. ## Usage ### Basic Considerations The recommended way to run a JMH benchmark is to use Maven to setup a standalone project that depends on the jar files of your application. This approach is preferred to ensure that the benchmarks are correctly initialized and produce reliable results. It is possible to run benchmarks from within an existing project, and even from within an IDE, however setup is more complex and the results are less reliable. In all cases, the key to using JMH is enabling the annotation- or bytecode-processors to generate the synthetic benchmark code. Maven archetypes are the primary mechanism used to bootstrap the project that has the proper build configuration. We strongly recommend new users make use of the archetype to setup the correct environment. ### Samples In order to understand JMH tests and maybe write your own, it might be useful to work through the [JMH Samples](https://github.com/openjdk/jmh/tree/master/jmh-samples/src/main/java/org/openjdk/jmh/samples). See the test comments for run instructions. ### Preferred Usage: Command Line **Step 1. Setting up the benchmarking project.** The following command will generate the new JMH-driven project in `test` folder: $ mvn archetype:generate \ -DinteractiveMode=false \ -DarchetypeGroupId=org.openjdk.jmh \ -DarchetypeArtifactId=jmh-java-benchmark-archetype \ -DgroupId=org.sample \ -DartifactId=test \ -Dversion=1.0 If you want to benchmark an alternative JVM language, use another archetype artifact ID from the [list of existing ones](https://repo.maven.apache.org/maven2/org/openjdk/jmh/), it usually amounts to replacing `java` to another language in the artifact ID given above. Using alternative archetypes may require additional changes in the build configuration, see the `pom.xml` in the generated project. **Step 2. Building the benchmarks.** After the project is generated, you can build it with the following Maven command: $ cd test/ $ mvn clean verify **Step 3. Running the benchmarks.** After the build is done, you will get the self-contained executable JAR, which holds your benchmark, and all essential JMH infrastructure code: $ java -jar target/benchmarks.jar Run with `-h` to see the command line options available. When dealing with large projects, it is customary to keep the benchmarks in a separate sub-project, which then depends on the tested modules via the usual build dependencies. ### IDE Support While the command line approach is the suggested one, some people prefer to use IDEs. The user experience varies between different IDEs, but we will outline the general things here. Running benchmarks from the IDE is generally not recommended due to generally uncontrolled environment in which the benchmarks run. **Step 1. Setting up the benchmarking project.** Some IDEs provide the GUI to create the Maven project from the given archetype. Make sure your IDE knows about Central archetype catalog, and look for `org.openjdk.jmh:jmh-${lang}-benchmark-archetype` there. Alternatively, you can use the command line to generate the benchmark project, see above. _NOTE: JMH is not intended to be used in the same way as a typical testing library such as JUnit. Simply adding the `jmh-core` jar file to your build is not enough to be able to run benchmarks._ **Step 2. Building the benchmarks.** Most IDEs are able to open/import Maven projects, and infer the build configuration from Maven project configuration. IDEA and NetBeans are able to build JMH benchmark projects with little to no effort. Eclipse build configuration may need to set up JMH annotation processors to run. **Step 3. Running the benchmarks.** There is no direct support for JMH benchmarks in the IDE, but one can use JMH Java API to invoke the benchmark. It usually amounts to having the `main` method, which will then call into JMH. See [JMH Samples](https://github.com/openjdk/jmh/tree/master/jmh-samples/src/main/java/org/openjdk/jmh/samples) for the examples of this approach. Before you run any benchmark, the project build is required. Most IDEs do this automatically, but some do require explicit build action to be added before the run: adding Maven target `verify` should help there. ### Other Build Systems JMH project does not ship the build scripts for build systems other that Maven. But there are community-supported bindings: - [Gradle JMH Plugin](https://github.com/melix/jmh-gradle-plugin) - [Scala SBT JMH Plugin](https://github.com/ktoso/sbt-jmh) If you want to build with an alternative build system, you may want to see the [Ant sample](https://github.com/openjdk/jmh/tree/master/jmh-ant-sample) which describes the steps to build JMH benchmark projects. ## Support and Development ### Pre-Requisite Steps Make sure you did this before publishing the benchmark, and/or requesting the JMH feature: - **JMH annotations Javadocs and Samples are essential reading.** Follow the [JMH Samples](https://github.com/openjdk/jmh/tree/master/jmh-samples/src/main/java/org/openjdk/jmh/samples) to get familiar with the API, use cases, culprits, and pitfalls in building the benchmarks and using JMH. - **Your benchmarks should be peer-reviewed.** Do not assume that a nice harness will magically free you from considering benchmarking pitfalls. We only promise to make avoiding them easier, not avoiding them completely. Make sure you tried these things before getting support: - **Archetypes provide the golden build configuration.** Try to generate the clean JMH benchmark project and transplant the benchmark there. This is important to try when upgrading to the newer JMH versions, since the minute differences in the build configurations may attribute to the failures you are seeing. - **Current development code is usually leaner, meaner, and better.** Make sure you are running the latest JMH version, and/or try to run with bleeding edge JMH to see if the issue is already fixed. - **See if your question/issue was discussed already.** Look around mailing list archives to see if there is already an answer. If all these did not help, you are welcome to report the issue. ### Reporting Harness and Test Bugs If you have the access to [OpenJDK Bug System](https://bugs.openjdk.org/browse/CODETOOLS-7902762?jql=project%20%3D%20CODETOOLS%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20tools%20AND%20Subcomponent%20%3D%20jmh), please submit the bug there: * Project: CODETOOLS * Component: tools * Sub-component: jmh Alternatively, you can join the [JMH Mailing List](https://mail.openjdk.org/mailman/listinfo/jmh-dev) and report the bugs there. ## Development JMH project accepts pull requests, like other OpenJDK projects. If you have never contributed to OpenJDK before, then bots would require you to [sign OCA first](http://openjdk.org/contribute). Normally, you don't need to post patches anywhere else, or post to mailing lists, etc. If you do want to have a wider discussion about JMH, please refer to [jmh-dev](https://mail.openjdk.org/mailman/listinfo/jmh-dev). Short instructions to build, test bleeding-edge JMH, and install its JAR to local Maven repo: $ mvn clean install If you already have the benchmark project, then it is enough to change JMH dependencies version to the latest `SNAPSHOT` version (look up the actual latest version in [root `pom.xml`](https://github.com/openjdk/jmh/blob/master/pom.xml)). If not, create the JMH benchmark project and change the version there. GitHub workflow "JMH Pre-Integration Tests" should pass on the changes. It would be triggered for PRs. You can also trigger it manually for your branch. ## Related projects These projects are supported by community, not by OpenJDK/JMH developers. - [IntelliJ IDEA JMH Plugin](https://github.com/artyushov/idea-jmh-plugin) - [Jenkins JMH Plugin](https://github.com/brianfromoregon/jmh-plugin) - [Teamcity JMH Plugin](https://github.com/presidentio/teamcity-plugin-jmh) - [Visualize JMH Benchmarks](https://github.com/jzillmann/jmh-visualizer) jmh-1.37/THIRD-PARTY000066400000000000000000000350611446271450100137250ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-ant-sample/000077500000000000000000000000001446271450100150435ustar00rootroot00000000000000jmh-1.37/jmh-ant-sample/LICENSE000066400000000000000000000455121446271450100160570ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-ant-sample/THIRD-PARTY000066400000000000000000000350611446271450100165420ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-ant-sample/build.xml000066400000000000000000000110401446271450100166600ustar00rootroot00000000000000 Sample Ant build file for using JMH without Maven. This is the unsupported way to run JMH, but still can be useful to understand the ways JMH compiles and runs. jmh-1.37/jmh-ant-sample/src/000077500000000000000000000000001446271450100156325ustar00rootroot00000000000000jmh-1.37/jmh-ant-sample/src/org/000077500000000000000000000000001446271450100164215ustar00rootroot00000000000000jmh-1.37/jmh-ant-sample/src/org/openjdk/000077500000000000000000000000001446271450100200535ustar00rootroot00000000000000jmh-1.37/jmh-ant-sample/src/org/openjdk/jmh/000077500000000000000000000000001446271450100206315ustar00rootroot00000000000000jmh-1.37/jmh-ant-sample/src/org/openjdk/jmh/MyAntyBench.java000066400000000000000000000027001446271450100236540ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh; import org.openjdk.jmh.annotations.Benchmark; import java.util.concurrent.TimeUnit; public class MyAntyBench { @Benchmark public void myTest() throws InterruptedException { TimeUnit.MILLISECONDS.sleep(1); } } jmh-1.37/jmh-archetypes/000077500000000000000000000000001446271450100151515ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/LICENSE000066400000000000000000000455121446271450100161650ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-archetypes/THIRD-PARTY000066400000000000000000000350611446271450100166500ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/000077500000000000000000000000001446271450100231645ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/LICENSE000066400000000000000000000455121446271450100242000ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/THIRD-PARTY000066400000000000000000000350611446271450100246630ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml000066400000000000000000000036371446271450100245120ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-archetypes 1.37 jmh-groovy-benchmark-archetype maven-archetype JMH Benchmark Archetype: Groovy Generates Groovy benchmarking project, uses JMH bytecode processors org.apache.maven.archetype archetype-packaging 2.2 org.apache.maven.plugins maven-archetype-plugin org.apache.maven.plugins maven-resources-plugin src/main/resources true archetype-resources/pom.xml src/main/resources false archetype-resources/pom.xml jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/000077500000000000000000000000001446271450100237535ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/000077500000000000000000000000001446271450100246775ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/000077500000000000000000000000001446271450100267115ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/LICENSE000066400000000000000000000455121446271450100277250ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/META-INF/000077500000000000000000000000001446271450100300515ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/META-INF/maven/000077500000000000000000000000001446271450100311575ustar00rootroot00000000000000archetype-metadata.xml000066400000000000000000000033421446271450100353660ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/META-INF/maven src/main/groovy **/*.groovy jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/THIRD-PARTY000066400000000000000000000350611446271450100304100ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/000077500000000000000000000000001446271450100327055ustar00rootroot00000000000000pom.xml000066400000000000000000000233471446271450100341540ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources 4.0.0 \${groupId} \${artifactId} \${version} jar JMH benchmark sample: Groovy org.openjdk.jmh jmh-core \${jmh.version} org.codehaus.groovy groovy \${groovy.version} UTF-8 ${project.version} 1.8 2.4.7 default benchmarks org.codehaus.mojo build-helper-maven-plugin 1.8 add-source generate-sources add-source \${project.basedir}/src/main/groovy \${project.basedir}/target/generated-sources/jmh org.codehaus.gmaven gmaven-plugin 1.5 process-sources compile testCompile 2.0 org.codehaus.mojo exec-maven-plugin 1.2.1 process-sources java true org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator \${project.basedir}/target/classes/ \${project.basedir}/target/generated-sources/jmh/ \${project.basedir}/target/classes/ \${jmh.generator} org.openjdk.jmh jmh-generator-bytecode \${jmh.version} org.apache.maven.plugins maven-compiler-plugin 3.8.0 \${javac.target} \${javac.target} \${javac.target} -proc:none org.apache.maven.plugins maven-shade-plugin 3.2.1 package shade \${uberjar.name} org.openjdk.jmh.Main *:* META-INF/*.SF META-INF/*.DSA META-INF/*.RSA jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/src/000077500000000000000000000000001446271450100334745ustar00rootroot00000000000000main/000077500000000000000000000000001446271450100343415ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/srcgroovy/000077500000000000000000000000001446271450100356665ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/src/mainMyBenchmark.groovy000066400000000000000000000036401446271450100413400ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/src/main/groovy/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package ${groupId} import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.Scope import org.openjdk.jmh.annotations.State @State(Scope.Benchmark) class MyBenchmark { @Benchmark def testMethod() { // This is a demo/sample template for building your JMH benchmarks. Edit as needed. // Put your benchmark code here. } } jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/000077500000000000000000000000001446271450100247325ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/000077500000000000000000000000001446271450100267445ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/000077500000000000000000000000001446271450100305755ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/test/000077500000000000000000000000001446271450100315545ustar00rootroot00000000000000archetype.properties000066400000000000000000000001701446271450100355750ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/testgroupId=org.openjdk.jmh artifactId=jmh-groovy-benchmark-archetype-test version=1.0-SNAPSHOT package=org.openjdk.jmh jmh-1.37/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/test/goal.txt000066400000000000000000000000061446271450100332330ustar00rootroot00000000000000verifyjmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/000077500000000000000000000000001446271450100225605ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/LICENSE000066400000000000000000000455121446271450100235740ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/THIRD-PARTY000066400000000000000000000350611446271450100242570ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml000066400000000000000000000057771446271450100241150ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-archetypes 1.37 jmh-java-benchmark-archetype maven-archetype JMH Benchmark Archetype: Java Generates Java benchmarking project, uses JMH annotation processors org.apache.maven.archetype archetype-packaging 2.2 org.apache.maven.plugins maven-archetype-plugin org.apache.maven.plugins maven-resources-plugin src/main/resources true archetype-resources/pom.xml src/main/resources false archetype-resources/pom.xml jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/000077500000000000000000000000001446271450100233475ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/000077500000000000000000000000001446271450100242735ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/000077500000000000000000000000001446271450100263055ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/LICENSE000066400000000000000000000455121446271450100273210ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/META-INF/000077500000000000000000000000001446271450100274455ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/META-INF/maven/000077500000000000000000000000001446271450100305535ustar00rootroot00000000000000archetype-metadata.xml000066400000000000000000000033341446271450100347630ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/META-INF/maven src/main/java **/*.java jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/THIRD-PARTY000066400000000000000000000350611446271450100300040ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/000077500000000000000000000000001446271450100323015ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml000066400000000000000000000156151446271450100336260ustar00rootroot00000000000000 4.0.0 \${groupId} \${artifactId} \${version} jar JMH benchmark sample: Java org.openjdk.jmh jmh-core \${jmh.version} org.openjdk.jmh jmh-generator-annprocess \${jmh.version} provided UTF-8 ${project.version} 1.8 benchmarks org.apache.maven.plugins maven-compiler-plugin 3.8.0 \${javac.target} \${javac.target} \${javac.target} org.apache.maven.plugins maven-shade-plugin 3.2.1 package shade \${uberjar.name} org.openjdk.jmh.Main *:* META-INF/*.SF META-INF/*.DSA META-INF/*.RSA maven-clean-plugin 2.5 maven-deploy-plugin 2.8.1 maven-install-plugin 2.5.1 maven-jar-plugin 2.4 maven-javadoc-plugin 2.9.1 maven-resources-plugin 2.6 maven-site-plugin 3.3 maven-source-plugin 2.2.1 maven-surefire-plugin 2.17 jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/src/000077500000000000000000000000001446271450100330705ustar00rootroot00000000000000main/000077500000000000000000000000001446271450100337355ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/srcjava/000077500000000000000000000000001446271450100346565ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/src/mainMyBenchmark.java000066400000000000000000000035071446271450100377260ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/src/main/java/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package ${groupId}; import org.openjdk.jmh.annotations.Benchmark; public class MyBenchmark { @Benchmark public void testMethod() { // This is a demo/sample template for building your JMH benchmarks. Edit as needed. // Put your benchmark code here. } } jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/test/000077500000000000000000000000001446271450100243265ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/test/resources/000077500000000000000000000000001446271450100263405ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/test/resources/projects/000077500000000000000000000000001446271450100301715ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/test/resources/projects/test/000077500000000000000000000000001446271450100311505ustar00rootroot00000000000000archetype.properties000066400000000000000000000001661446271450100351760ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/test/resources/projects/testgroupId=org.openjdk.jmh artifactId=jmh-java-benchmark-archetype-test version=1.0-SNAPSHOT package=org.openjdk.jmh jmh-1.37/jmh-archetypes/jmh-java-benchmark-archetype/src/test/resources/projects/test/goal.txt000066400000000000000000000000061446271450100326270ustar00rootroot00000000000000verifyjmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/000077500000000000000000000000001446271450100231375ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/LICENSE000066400000000000000000000455121446271450100241530ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/THIRD-PARTY000066400000000000000000000350611446271450100246360ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml000066400000000000000000000036371446271450100244650ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-archetypes 1.37 jmh-kotlin-benchmark-archetype maven-archetype JMH Benchmark Archetype: Kotlin Generates Kotlin benchmarking project, uses JMH bytecode processors org.apache.maven.archetype archetype-packaging 2.2 org.apache.maven.plugins maven-archetype-plugin org.apache.maven.plugins maven-resources-plugin src/main/resources true archetype-resources/pom.xml src/main/resources false archetype-resources/pom.xml jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/000077500000000000000000000000001446271450100237265ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/000077500000000000000000000000001446271450100246525ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/000077500000000000000000000000001446271450100266645ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/LICENSE000066400000000000000000000455121446271450100277000ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/META-INF/000077500000000000000000000000001446271450100300245ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/META-INF/maven/000077500000000000000000000000001446271450100311325ustar00rootroot00000000000000archetype-metadata.xml000066400000000000000000000033361446271450100353440ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/META-INF/maven src/main/kotlin **/*.kt jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/THIRD-PARTY000066400000000000000000000350611446271450100303630ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/000077500000000000000000000000001446271450100326605ustar00rootroot00000000000000pom.xml000066400000000000000000000244331446271450100341240ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources 4.0.0 \${groupId} \${artifactId} \${version} jar JMH benchmark sample: Kotlin org.openjdk.jmh jmh-core \${jmh.version} org.jetbrains.kotlin kotlin-stdlib \${kotlin.version} UTF-8 ${project.version} 1.8 1.5.30 default benchmarks kotlin-maven-plugin org.jetbrains.kotlin \${kotlin.version} process-sources generate-sources compile \${project.basedir}/src/main/kotlin process-test-sources test-compile test-compile org.codehaus.mojo exec-maven-plugin 1.2.1 process-sources java true org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator \${project.basedir}/target/classes/ \${project.basedir}/target/generated-sources/jmh/ \${project.basedir}/target/classes/ \${jmh.generator} org.openjdk.jmh jmh-generator-bytecode \${jmh.version} org.codehaus.mojo build-helper-maven-plugin 1.8 add-source process-sources add-source \${project.basedir}/target/generated-sources/jmh org.apache.maven.plugins maven-compiler-plugin 3.8.0 \${javac.target} \${javac.target} \${javac.target} -proc:none org.apache.maven.plugins maven-shade-plugin 3.2.1 package shade \${uberjar.name} org.openjdk.jmh.Main *:* META-INF/*.SF META-INF/*.DSA META-INF/*.RSA jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/src/000077500000000000000000000000001446271450100334475ustar00rootroot00000000000000main/000077500000000000000000000000001446271450100343145ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/srckotlin/000077500000000000000000000000001446271450100356145ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/src/mainMyBenchmark.kt000066400000000000000000000034731446271450100403630ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/src/main/kotlin/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package ${groupId} import org.openjdk.jmh.annotations.Benchmark open class MyBenchmark { @Benchmark fun testMethod() { // This is a demo/sample template for building your JMH benchmarks. Edit as needed. // Put your benchmark code here. } } jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/000077500000000000000000000000001446271450100247055ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/000077500000000000000000000000001446271450100267175ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/000077500000000000000000000000001446271450100305505ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/test/000077500000000000000000000000001446271450100315275ustar00rootroot00000000000000archetype.properties000066400000000000000000000001701446271450100355500ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/testgroupId=org.openjdk.jmh artifactId=jmh-kotlin-benchmark-archetype-test version=1.0-SNAPSHOT package=org.openjdk.jmh jmh-1.37/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/test/goal.txt000066400000000000000000000000061446271450100332060ustar00rootroot00000000000000verifyjmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/000077500000000000000000000000001446271450100227225ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/LICENSE000066400000000000000000000455121446271450100237360ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/THIRD-PARTY000066400000000000000000000350611446271450100244210ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml000066400000000000000000000036341446271450100242450ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-archetypes 1.37 jmh-scala-benchmark-archetype maven-archetype JMH Benchmark Archetype: Scala Generates Scala benchmarking project, uses JMH bytecode processors org.apache.maven.archetype archetype-packaging 2.2 org.apache.maven.plugins maven-archetype-plugin org.apache.maven.plugins maven-resources-plugin src/main/resources true archetype-resources/pom.xml src/main/resources false archetype-resources/pom.xml jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/000077500000000000000000000000001446271450100235115ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/000077500000000000000000000000001446271450100244355ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/000077500000000000000000000000001446271450100264475ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/LICENSE000066400000000000000000000455121446271450100274630ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/META-INF/000077500000000000000000000000001446271450100276075ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/META-INF/maven/000077500000000000000000000000001446271450100307155ustar00rootroot00000000000000archetype-metadata.xml000066400000000000000000000033371446271450100351300ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/META-INF/maven src/main/scala **/*.scala jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/THIRD-PARTY000066400000000000000000000350611446271450100301460ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/000077500000000000000000000000001446271450100324435ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml000066400000000000000000000240011446271450100337550ustar00rootroot00000000000000 4.0.0 \${groupId} \${artifactId} \${version} jar JMH benchmark sample: Scala org.openjdk.jmh jmh-core \${jmh.version} org.scala-lang scala-library \${scala.stdLib.version} UTF-8 ${project.version} 1.8 2.11.8 3.2.2 default benchmarks org.codehaus.mojo build-helper-maven-plugin 1.8 add-source generate-sources add-source \${project.basedir}/src/main/scala \${project.basedir}/target/generated-sources/jmh net.alchim31.maven scala-maven-plugin \${scala.mavenPlugin.version} incremental process-sources compile org.codehaus.mojo exec-maven-plugin 1.2.1 process-sources java true org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator \${project.basedir}/target/classes/ \${project.basedir}/target/generated-sources/jmh/ \${project.basedir}/target/classes/ \${jmh.generator} org.openjdk.jmh jmh-generator-bytecode \${jmh.version} org.apache.maven.plugins maven-compiler-plugin 3.8.0 \${javac.target} \${javac.target} \${javac.target} -proc:none org.apache.maven.plugins maven-shade-plugin 3.2.1 package shade \${uberjar.name} org.openjdk.jmh.Main *:* META-INF/*.SF META-INF/*.DSA META-INF/*.RSA jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/src/000077500000000000000000000000001446271450100332325ustar00rootroot00000000000000main/000077500000000000000000000000001446271450100340775ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/srcscala/000077500000000000000000000000001446271450100351625ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/src/mainMyBenchmark.scala000066400000000000000000000034571446271450100404000ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/src/main/scala/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package ${groupId} import org.openjdk.jmh.annotations.Benchmark class MyBenchmark { @Benchmark def testMethod(): Any = { // This is a demo/sample template for building your JMH benchmarks. Edit as needed. // Put your benchmark code here. } } jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/000077500000000000000000000000001446271450100244705ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/000077500000000000000000000000001446271450100265025ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/000077500000000000000000000000001446271450100303335ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/test/000077500000000000000000000000001446271450100313125ustar00rootroot00000000000000archetype.properties000066400000000000000000000001671446271450100353410ustar00rootroot00000000000000jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/testgroupId=org.openjdk.jmh artifactId=jmh-scala-benchmark-archetype-test version=1.0-SNAPSHOT package=org.openjdk.jmh jmh-1.37/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/test/goal.txt000066400000000000000000000000061446271450100327710ustar00rootroot00000000000000verifyjmh-1.37/jmh-archetypes/pom.xml000066400000000000000000000100151446271450100164630ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent 1.37 JMH Archetypes jmh-archetypes pom UTF-8 jdk8 1.8 maven-archetype-plugin 3.0.1 integration-test false others true maven-archetype-plugin 3.0.1 integration-test true org.apache.maven.plugins maven-resources-plugin \ jmh-java-benchmark-archetype jmh-scala-benchmark-archetype jmh-groovy-benchmark-archetype jmh-kotlin-benchmark-archetype jmh-1.37/jmh-core-benchmarks/000077500000000000000000000000001446271450100160455ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/LICENSE000066400000000000000000000455121446271450100170610ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-core-benchmarks/THIRD-PARTY000066400000000000000000000350611446271450100175440ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-core-benchmarks/pom.xml000066400000000000000000000141551446271450100173700ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent 1.37 JMH Core Benchmarks jmh-core-benchmarks jar Oracle http://openjdk.java.net/ 2012 org.openjdk.jmh jmh-core ${project.version} org.openjdk.jmh jmh-generator-annprocess ${project.version} provided net.java.dev.jna jna 5.8.0 net.java.dev.jna jna-platform 5.8.0 UTF-8 org.apache.maven.plugins maven-compiler-plugin org.apache.maven.plugins maven-surefire-plugin always true org.apache.maven.plugins maven-shade-plugin benchmarks package shade benchmarks org.openjdk.jmh.Main validation package shade jmh-core-benchmarks true full org.openjdk.jmh.validation.Main com.mycila.maven-license-plugin maven-license-plugin format process-sources
file:///${project.basedir}/../src/license/gpl_cpe/header.txt
true true PHP
jmh-1.37/jmh-core-benchmarks/src/000077500000000000000000000000001446271450100166345ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/000077500000000000000000000000001446271450100175605ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/LICENSE000066400000000000000000000455121446271450100205740ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-core-benchmarks/src/main/THIRD-PARTY000066400000000000000000000350611446271450100212570ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-core-benchmarks/src/main/java/000077500000000000000000000000001446271450100205015ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/000077500000000000000000000000001446271450100212705ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/000077500000000000000000000000001446271450100227225ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/000077500000000000000000000000001446271450100235005ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/000077500000000000000000000000001446271450100256155ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeBench.java000066400000000000000000000073271446271450100313150ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) public class BlackholeBench { private List strs; @Setup(Level.Iteration) public void makeGarbage() { // make some garbage to evict blackhole from the TLAB/eden strs = new ArrayList<>(); for (int i = 0; i < 100_000; i++) { strs.add("str" + i); } } public byte b; public boolean bool; public char c; public short s; public int i; public long l; public float f; public double d; public Object o; public Object[] os; @Benchmark public void baseline() { // do nothing } @Benchmark public byte implicit_byte() { return b; } @Benchmark public boolean implicit_boolean() { return bool; } @Benchmark public char implicit_char() { return c; } @Benchmark public short implicit_short() { return s; } @Benchmark public int implicit_int() { return i; } @Benchmark public long implicit_long() { return l; } @Benchmark public float implicit_float() { return f; } @Benchmark public double implicit_double() { return d; } @Benchmark public Object implicit_Object() { return o; } @Benchmark public Object[] implicit_Array() { return os; } @Benchmark public void explicit_byte(Blackhole bh) { bh.consume(b); } @Benchmark public void explicit_boolean(Blackhole bh) { bh.consume(bool); } @Benchmark public void explicit_char(Blackhole bh) { bh.consume(c); } @Benchmark public void explicit_short(Blackhole bh) { bh.consume(s); } @Benchmark public void explicit_int(Blackhole bh) { bh.consume(i); } @Benchmark public void explicit_long(Blackhole bh) { bh.consume(l); } @Benchmark public void explicit_float(Blackhole bh) { bh.consume(f); } @Benchmark public void explicit_double(Blackhole bh) { bh.consume(d); } @Benchmark public void explicit_Object(Blackhole bh) { bh.consume(o); } @Benchmark public void explicit_Array(Blackhole bh) { bh.consume(os); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeConsecutiveBench.java000066400000000000000000000206611446271450100335210ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.concurrent.TimeUnit; @OutputTimeUnit(TimeUnit.NANOSECONDS) @BenchmarkMode(Mode.AverageTime) @State(Scope.Thread) public class BlackholeConsecutiveBench { private int x = 4242; private int y = 1414; @Benchmark public void test_boolean_1(Blackhole bh) { bh.consume((x / y + 1331) > 0); } @Benchmark public void test_boolean_4(Blackhole bh) { bh.consume((x / y + 1331) > 0); bh.consume((x / y + 1331) > 0); bh.consume((x / y + 1331) > 0); bh.consume((x / y + 1331) > 0); } @Benchmark public void test_boolean_8(Blackhole bh) { bh.consume((x / y + 1331) > 0); bh.consume((x / y + 1331) > 0); bh.consume((x / y + 1331) > 0); bh.consume((x / y + 1331) > 0); bh.consume((x / y + 1331) > 0); bh.consume((x / y + 1331) > 0); bh.consume((x / y + 1331) > 0); bh.consume((x / y + 1331) > 0); } @Benchmark public void test_byte_1(Blackhole bh) { bh.consume((byte) (x / y + 1331)); } @Benchmark public void test_byte_4(Blackhole bh) { bh.consume((byte) (x / y + 1331)); bh.consume((byte) (x / y + 1331)); bh.consume((byte) (x / y + 1331)); bh.consume((byte) (x / y + 1331)); } @Benchmark public void test_byte_8(Blackhole bh) { bh.consume((byte) (x / y + 1331)); bh.consume((byte) (x / y + 1331)); bh.consume((byte) (x / y + 1331)); bh.consume((byte) (x / y + 1331)); bh.consume((byte) (x / y + 1331)); bh.consume((byte) (x / y + 1331)); bh.consume((byte) (x / y + 1331)); bh.consume((byte) (x / y + 1331)); } @Benchmark public void test_short_1(Blackhole bh) { bh.consume((short) (x / y + 1331)); } @Benchmark public void test_short_4(Blackhole bh) { bh.consume((short) (x / y + 1331)); bh.consume((short) (x / y + 1331)); bh.consume((short) (x / y + 1331)); bh.consume((short) (x / y + 1331)); } @Benchmark public void test_short_8(Blackhole bh) { bh.consume((short) (x / y + 1331)); bh.consume((short) (x / y + 1331)); bh.consume((short) (x / y + 1331)); bh.consume((short) (x / y + 1331)); bh.consume((short) (x / y + 1331)); bh.consume((short) (x / y + 1331)); bh.consume((short) (x / y + 1331)); bh.consume((short) (x / y + 1331)); } @Benchmark public void test_char_1(Blackhole bh) { bh.consume((char) (x / y + 1331)); } @Benchmark public void test_char_4(Blackhole bh) { bh.consume((char) (x / y + 1331)); bh.consume((char) (x / y + 1331)); bh.consume((char) (x / y + 1331)); bh.consume((char) (x / y + 1331)); } @Benchmark public void test_char_8(Blackhole bh) { bh.consume((char) (x / y + 1331)); bh.consume((char) (x / y + 1331)); bh.consume((char) (x / y + 1331)); bh.consume((char) (x / y + 1331)); bh.consume((char) (x / y + 1331)); bh.consume((char) (x / y + 1331)); bh.consume((char) (x / y + 1331)); bh.consume((char) (x / y + 1331)); } @Benchmark public void test_int_1(Blackhole bh) { bh.consume((int) (x / y + 1331)); } @Benchmark public void test_int_4(Blackhole bh) { bh.consume((int) (x / y + 1331)); bh.consume((int) (x / y + 1331)); bh.consume((int) (x / y + 1331)); bh.consume((int) (x / y + 1331)); } @Benchmark public void test_int_8(Blackhole bh) { bh.consume((int) (x / y + 1331)); bh.consume((int) (x / y + 1331)); bh.consume((int) (x / y + 1331)); bh.consume((int) (x / y + 1331)); bh.consume((int) (x / y + 1331)); bh.consume((int) (x / y + 1331)); bh.consume((int) (x / y + 1331)); bh.consume((int) (x / y + 1331)); } @Benchmark public void test_float_1(Blackhole bh) { bh.consume((float) (x / y + 1331)); } @Benchmark public void test_float_4(Blackhole bh) { bh.consume((float) (x / y + 1331)); bh.consume((float) (x / y + 1331)); bh.consume((float) (x / y + 1331)); bh.consume((float) (x / y + 1331)); } @Benchmark public void test_float_8(Blackhole bh) { bh.consume((float) (x / y + 1331)); bh.consume((float) (x / y + 1331)); bh.consume((float) (x / y + 1331)); bh.consume((float) (x / y + 1331)); bh.consume((float) (x / y + 1331)); bh.consume((float) (x / y + 1331)); bh.consume((float) (x / y + 1331)); bh.consume((float) (x / y + 1331)); } @Benchmark public void test_long_1(Blackhole bh) { bh.consume((long) (x / y + 1331)); } @Benchmark public void test_long_4(Blackhole bh) { bh.consume((long) (x / y + 1331)); bh.consume((long) (x / y + 1331)); bh.consume((long) (x / y + 1331)); bh.consume((long) (x / y + 1331)); } @Benchmark public void test_long_8(Blackhole bh) { bh.consume((long) (x / y + 1331)); bh.consume((long) (x / y + 1331)); bh.consume((long) (x / y + 1331)); bh.consume((long) (x / y + 1331)); bh.consume((long) (x / y + 1331)); bh.consume((long) (x / y + 1331)); bh.consume((long) (x / y + 1331)); bh.consume((long) (x / y + 1331)); } @Benchmark public void test_double_1(Blackhole bh) { bh.consume((double) (x / y + 1331)); } @Benchmark public void test_double_4(Blackhole bh) { bh.consume((double) (x / y + 1331)); bh.consume((double) (x / y + 1331)); bh.consume((double) (x / y + 1331)); bh.consume((double) (x / y + 1331)); } @Benchmark public void test_double_8(Blackhole bh) { bh.consume((double) (x / y + 1331)); bh.consume((double) (x / y + 1331)); bh.consume((double) (x / y + 1331)); bh.consume((double) (x / y + 1331)); bh.consume((double) (x / y + 1331)); bh.consume((double) (x / y + 1331)); bh.consume((double) (x / y + 1331)); bh.consume((double) (x / y + 1331)); } @Benchmark public void test_Object_1(Blackhole bh) { bh.consume(cachedObject(x / y + 1331)); } @Benchmark public void test_Object_4(Blackhole bh) { bh.consume(cachedObject(x / y + 1331)); bh.consume(cachedObject(x / y + 1331)); bh.consume(cachedObject(x / y + 1331)); bh.consume(cachedObject(x / y + 1331)); } @Benchmark public void test_Object_8(Blackhole bh) { bh.consume(cachedObject(x / y + 1331)); bh.consume(cachedObject(x / y + 1331)); bh.consume(cachedObject(x / y + 1331)); bh.consume(cachedObject(x / y + 1331)); bh.consume(cachedObject(x / y + 1331)); bh.consume(cachedObject(x / y + 1331)); bh.consume(cachedObject(x / y + 1331)); bh.consume(cachedObject(x / y + 1331)); } private Object cachedObject(int v) { if (v == 4242/1414 + 1331) { return 42; } else { return v; } } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeConsumeCPUBench.java000066400000000000000000000033541446271450100332130ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(3) @State(Scope.Benchmark) public class BlackholeConsumeCPUBench { @Param("0") private int delay; @Benchmark public void consume() { Blackhole.consumeCPU(delay); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholePipelineBench.java000066400000000000000000000102401446271450100327670ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.Random; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class BlackholePipelineBench { @Param("10") private int steps; private boolean[] booleans; private byte[] bytes; private short[] shorts; private char[] chars; private int[] ints; private float[] floats; private long[] longs; private double[] doubles; private Object[] objects; private Object[][] arrays; @Setup public void prepare() { booleans = new boolean[steps]; bytes = new byte[steps]; shorts = new short[steps]; chars = new char[steps]; ints = new int[steps]; floats = new float[steps]; longs = new long[steps]; doubles = new double[steps]; objects = new Object[steps]; arrays = new Object[steps][]; Random r = new Random(0); for (int c = 0; c < steps; c++) { booleans[c] = r.nextBoolean(); bytes[c] = (byte) r.nextInt(); shorts[c] = (short) r.nextInt(); chars[c] = (char) r.nextInt(); ints[c] = r.nextInt(); floats[c] = r.nextFloat(); longs[c] = r.nextLong(); doubles[c] = r.nextDouble(); objects[c] = new Object(); arrays[c] = new Object[10]; } } @Benchmark public void test_boolean(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(booleans[c]); } } @Benchmark public void test_byte(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(bytes[c]); } } @Benchmark public void test_short(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(shorts[c]); } } @Benchmark public void test_char(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(chars[c]); } } @Benchmark public void test_int(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(ints[c]); } } @Benchmark public void test_float(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(floats[c]); } } @Benchmark public void test_long(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(longs[c]); } } @Benchmark public void test_double(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(doubles[c]); } } @Benchmark public void test_Object(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(objects[c]); } } @Benchmark public void test_Array(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(arrays[c]); } } } BlackholePipelinePayloadBench.java000066400000000000000000000103461446271450100342310ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class BlackholePipelinePayloadBench { @Param("10") private int steps; private boolean[] booleans; private byte[] bytes; private short[] shorts; private char[] chars; private int[] ints; private float[] floats; private long[] longs; private double[] doubles; private Double[] objects; private Double[][] arrays; @Setup public void prepare() { booleans = new boolean[steps]; bytes = new byte[steps]; shorts = new short[steps]; chars = new char[steps]; ints = new int[steps]; floats = new float[steps]; longs = new long[steps]; doubles = new double[steps]; objects = new Double[steps]; arrays = new Double[steps][]; for (int c = 0; c < steps; c++) { booleans[c] = ((c & 1) == 0); bytes[c] = (byte) c; shorts[c] = (short) c; chars[c] = (char) c; ints[c] = c; floats[c] = c; longs[c] = c; doubles[c] = c; objects[c] = (double) c; arrays[c] = new Double[]{(double) c}; } } @Benchmark public void test_boolean(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume((Math.log(doubles[c]) > 1) ^ booleans[c]); } } @Benchmark public void test_byte(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume((byte)Math.log(bytes[c])); } } @Benchmark public void test_short(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume((short)Math.log(shorts[c])); } } @Benchmark public void test_char(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume((char)Math.log(chars[c])); } } @Benchmark public void test_int(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume((int)Math.log(ints[c])); } } @Benchmark public void test_float(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume((float)Math.log(floats[c])); } } @Benchmark public void test_long(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume((long)Math.log(longs[c])); } } @Benchmark public void test_double(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume((double)Math.log(doubles[c])); } } @Benchmark public void test_Object(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume((Double) Math.log(objects[c])); } } @Benchmark public void test_Array(Blackhole bh) { for (int c = 0; c < steps; c++) { bh.consume(new Double[] {Math.log(arrays[c][0])}); } } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeValueBench.java000066400000000000000000000042101446271450100322760ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.Random; import java.util.concurrent.TimeUnit; @OutputTimeUnit(TimeUnit.NANOSECONDS) @BenchmarkMode(Mode.AverageTime) @State(Scope.Thread) public class BlackholeValueBench { // TODO: Revisit Blackhole implementation // This benchmark highlights the problem with current consume code, // which is sensitive to what value we are going to hit inside. // Normally, this is solved with more forks, whereas Blackhole // randomizes the value it matches against. boolean[] array = new boolean[1000]; @Setup public void setup() { Random random = new Random(0); for (int i = 0; i < array.length; i++) { array[i] = random.nextBoolean(); } } @Benchmark public void test(Blackhole bh) { for (boolean b : array) { bh.consume(b); } } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BurstStabilityBench.java000066400000000000000000000034471446271450100324140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Warmup(iterations = 50) @Measurement(iterations = 50) @Threads(1) @State(Scope.Thread) public class BurstStabilityBench { @Param("10") private int delay; @Setup(Level.Iteration) public void sleep() throws InterruptedException { TimeUnit.MILLISECONDS.sleep(delay); } @Benchmark public void test() { Blackhole.consumeCPU(1_000_000); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/CompilerHintsBench.java000066400000000000000000000055441446271450100322100ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) public class CompilerHintsBench { @Benchmark public void baseI_baseline() { do_Plain(Math.PI); } @Benchmark @Fork(jvmArgsPrepend = {"-XX:MaxInlineSize=0", "-XX:FreqInlineSize=0"}) public void baseNI_baseline() { do_Plain(Math.PI); } @Benchmark public void baseI_inline() { do_Inline(Math.PI); } @Benchmark @Fork(jvmArgsPrepend = {"-XX:MaxInlineSize=0", "-XX:FreqInlineSize=0"}) public void baseNI_inline() { do_Inline(Math.PI); } @Benchmark public void baseI_dontInline() { do_DontInline(Math.PI); } @Benchmark @Fork(jvmArgsPrepend = {"-XX:MaxInlineSize=0", "-XX:FreqInlineSize=0"}) public void baseNI_dontInline() { do_DontInline(Math.PI); } @Benchmark public void baseI_exclude() { do_Exclude(Math.PI); } @Benchmark @Fork(jvmArgsPrepend = {"-XX:MaxInlineSize=0", "-XX:FreqInlineSize=0"}) public void baseNI_exclude() { do_Exclude(Math.PI); } private double do_Plain(double x) { return Math.log(x); } @CompilerControl(CompilerControl.Mode.INLINE) private double do_Inline(double x) { return Math.log(x); } @CompilerControl(CompilerControl.Mode.DONT_INLINE) private double do_DontInline(double x) { return Math.log(x); } @CompilerControl(CompilerControl.Mode.EXCLUDE) private double do_Exclude(double x) { return Math.log(x); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/CoreStabilityBench.java000066400000000000000000000035511446271450100322010ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.validation.AffinitySupport; import org.openjdk.jmh.validation.SpinWaitSupport; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) @Threads(1) @State(Scope.Thread) public class CoreStabilityBench { @Param("-1") int p; @Setup public void setup() { if (p == -1) { throw new IllegalStateException("Should provide a CPU number"); } AffinitySupport.bind(p); } @Benchmark public void test() { Blackhole.consumeCPU(1_000_000); } } CurrentTimeMillisTimerBench.java000066400000000000000000000035311446271450100337570ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import java.util.concurrent.TimeUnit; @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) public class CurrentTimeMillisTimerBench { private long last; @Benchmark public long latency() { return System.currentTimeMillis(); } @Benchmark public long granularity() { long lst = last; long cur; do { cur = System.currentTimeMillis(); } while (cur == lst); last = cur; return cur; } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/EmptyBench.java000066400000000000000000000034711446271450100305230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Warmup; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) public class EmptyBench { @Benchmark public void empty() { } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelInvocationBench.java000066400000000000000000000061401446271450100325220ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) public class LevelInvocationBench { @State(Scope.Benchmark) public static class BenchmarkSetup { @Setup(Level.Invocation) public void setup() {} } @State(Scope.Benchmark) public static class BenchmarkTeardown { @TearDown(Level.Invocation) public void tearDown() {} } @State(Scope.Thread) public static class ThreadSetup { @Setup(Level.Invocation) public void setup() {} } @State(Scope.Thread) public static class ThreadTeardown { @TearDown(Level.Invocation) public void tearDown() {} } @State(Scope.Group) public static class GroupSetup { @Setup(Level.Invocation) public void setup() {} } @State(Scope.Group) public static class GroupTeardown { @TearDown(Level.Invocation) public void tearDown() {} } @Benchmark @OutputTimeUnit(TimeUnit.NANOSECONDS) public void raw() { // do nothing } @Benchmark public void benchmark_setup(BenchmarkSetup g) {} @Benchmark public void benchmark_teardown(BenchmarkTeardown g) {} @Benchmark @Group("group_setup") public void group_setup_1(GroupSetup g) {} @Benchmark @Group("group_setup") public void group_setup_2(GroupSetup g) {} @Benchmark @Group("group_teardown") public void group_teardown_1(GroupTeardown g) {} @Benchmark @Group("group_teardown") public void group_teardown_2(GroupTeardown g) {} @Benchmark public void thread_setup(ThreadSetup g) {} @Benchmark public void thread_teardown(ThreadTeardown g) {} } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelIterationBench.java000066400000000000000000000061311446271450100323470ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) public class LevelIterationBench { @State(Scope.Benchmark) public static class BenchmarkSetup { @Setup(Level.Iteration) public void setup() {} } @State(Scope.Benchmark) public static class BenchmarkTeardown { @TearDown(Level.Iteration) public void tearDown() {} } @State(Scope.Thread) public static class ThreadSetup { @Setup(Level.Iteration) public void setup() {} } @State(Scope.Thread) public static class ThreadTeardown { @TearDown(Level.Iteration) public void tearDown() {} } @State(Scope.Group) public static class GroupSetup { @Setup(Level.Iteration) public void setup() {} } @State(Scope.Group) public static class GroupTeardown { @TearDown(Level.Iteration) public void tearDown() {} } @Benchmark @OutputTimeUnit(TimeUnit.NANOSECONDS) public void raw() { // do nothing } @Benchmark public void benchmark_setup(BenchmarkSetup g) {} @Benchmark public void benchmark_teardown(BenchmarkTeardown g) {} @Benchmark @Group("group_setup") public void group_setup_1(GroupSetup g) {} @Benchmark @Group("group_setup") public void group_setup_2(GroupSetup g) {} @Benchmark @Group("group_teardown") public void group_teardown_1(GroupTeardown g) {} @Benchmark @Group("group_teardown") public void group_teardown_2(GroupTeardown g) {} @Benchmark public void thread_setup(ThreadSetup g) {} @Benchmark public void thread_teardown(ThreadTeardown g) {} } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LevelTrialBench.java000066400000000000000000000060751446271450100314730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) public class LevelTrialBench { @State(Scope.Benchmark) public static class BenchmarkSetup { @Setup(Level.Trial) public void setup() {} } @State(Scope.Benchmark) public static class BenchmarkTeardown { @TearDown(Level.Trial) public void tearDown() {} } @State(Scope.Thread) public static class ThreadSetup { @Setup(Level.Trial) public void setup() {} } @State(Scope.Thread) public static class ThreadTeardown { @TearDown(Level.Trial) public void tearDown() {} } @State(Scope.Group) public static class GroupSetup { @Setup(Level.Trial) public void setup() {} } @State(Scope.Group) public static class GroupTeardown { @TearDown(Level.Trial) public void tearDown() {} } @Benchmark @OutputTimeUnit(TimeUnit.NANOSECONDS) public void raw() { // do nothing } @Benchmark public void benchmark_setup(BenchmarkSetup g) {} @Benchmark public void benchmark_teardown(BenchmarkTeardown g) {} @Benchmark @Group("group_setup") public void group_setup_1(GroupSetup g) {} @Benchmark @Group("group_setup") public void group_setup_2(GroupSetup g) {} @Benchmark @Group("group_teardown") public void group_teardown_1(GroupTeardown g) {} @Benchmark @Group("group_teardown") public void group_teardown_2(GroupTeardown g) {} @Benchmark public void thread_setup(ThreadSetup g) {} @Benchmark public void thread_teardown(ThreadTeardown g) {} } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LongStabilityBench.java000066400000000000000000000030551446271450100322070ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) @Threads(1) @State(Scope.Thread) public class LongStabilityBench { @Benchmark public void test() { Blackhole.consumeCPU(1_000_000); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/NanoTimerBench.java000066400000000000000000000041771446271450100313250ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import java.util.concurrent.TimeUnit; @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) public class NanoTimerBench { private long last; @Benchmark public long latency() { return System.nanoTime(); } @Benchmark public long granularity() { long lst = last; long cur; do { cur = System.nanoTime(); } while (cur == lst); last = cur; return cur; } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/RoundTripLatencyBench.java000066400000000000000000000046261446271450100326760ustar00rootroot00000000000000/* * Copyright (c) 2023, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.validation.SpinWaitSupport; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.validation.AffinitySupport; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) public class RoundTripLatencyBench { static final boolean SPINWAIT = Boolean.getBoolean("spinWait"); @Param("-1") int p; @Param("-1") int c; Thread t; volatile boolean ping; @Setup public void setup() { if (c != -1) AffinitySupport.bind(c); t = new Thread(() -> { if (p != -1) AffinitySupport.bind(p); Thread t = Thread.currentThread(); while (!t.isInterrupted()) { while (!ping) { if (SPINWAIT) SpinWaitSupport.onSpinWait(); } ping = false; } }); t.start(); } @TearDown public void tearDown() throws InterruptedException { t.interrupt(); ping = true; t.join(); } @Benchmark public void test() { ping = true; while (ping) { if (SPINWAIT) SpinWaitSupport.onSpinWait(); } } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ThermalRundownBench.java000066400000000000000000000030631446271450100323730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) public class ThermalRundownBench { @Benchmark public void test() { Blackhole.consumeCPU(1_000_000); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ThreadScalingBench.java000066400000000000000000000030621446271450100321310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.benchmarks; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) public class ThreadScalingBench { @Benchmark public void test() { Blackhole.consumeCPU(1_000_000); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/000077500000000000000000000000001446271450100256325ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/AffinitySupport.java000066400000000000000000000137021446271450100316460ustar00rootroot00000000000000/* * Copyright (c) 2023, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation; import com.sun.jna.*; import java.io.File; import java.util.Arrays; import java.util.Collections; import java.util.List; public class AffinitySupport { public static boolean isLinux() { return System.getProperty("os.name").toLowerCase().contains("linux"); } public static boolean isSupported() { return isLinux(); } public static void bind(int cpu) { if (isLinux()) { Linux.bind(cpu); } else { throw new IllegalStateException("Not implemented"); } } public static void tryBind() { if (isLinux()) { Linux.tryBind(); } else { throw new IllegalStateException("Not implemented"); } } public static List prepare() { if (isLinux()) { return Linux.prepare(); } else { throw new IllegalStateException("Not implemented"); } } public static void tryInit() { if (isLinux()) { Linux.tryInit(); } } static class Linux { private static volatile CLibrary INSTANCE; private static boolean BIND_TRIED; /* Unpacks the libraries, and replies additional options for forked VMs. */ public static List prepare() { System.setProperty("jnidispatch.preserve", "true"); Native.load("c", CLibrary.class); File file = new File(System.getProperty("jnidispatch.path")); String bootLibraryPath = file.getParent(); // Need to rename the file to the proper name, otherwise JNA would not discover it File proper = new File(bootLibraryPath + '/' + System.mapLibraryName("jnidispatch")); if (!file.renameTo(proper)) { throw new IllegalStateException("Failed to rename " + file + " to " + proper); } return Arrays.asList( "-Djna.nounpack=true", // Should not unpack itself, but use predefined path "-Djna.nosys=true", // Should load from explicit path "-Djna.noclasspath=true", // Should load from explicit path "-Djna.boot.library.path=" + bootLibraryPath, "-Djna.platform.library.path=" + System.getProperty("jna.platform.library.path") ); } public static void tryInit() { if (INSTANCE == null) { synchronized (Linux.class) { if (INSTANCE == null) { INSTANCE = Native.load("c", CLibrary.class); } } } } public static void bind(int cpu) { tryInit(); final cpu_set_t cpuset = new cpu_set_t(); cpuset.set(cpu); set(cpuset); } public static void tryBind() { if (BIND_TRIED) return; synchronized (Linux.class) { if (BIND_TRIED) return; tryInit(); cpu_set_t cs = new cpu_set_t(); get(cs); set(cs); BIND_TRIED = true; } } private static void get(cpu_set_t cpuset) { if (INSTANCE.sched_getaffinity(0, cpu_set_t.SIZE_OF, cpuset) != 0) { throw new IllegalStateException("Failed: " + Native.getLastError()); } } private static void set(cpu_set_t cpuset) { if (INSTANCE.sched_setaffinity(0, cpu_set_t.SIZE_OF, cpuset) != 0) { throw new IllegalStateException("Failed: " + Native.getLastError()); } } interface CLibrary extends Library { int sched_getaffinity(int pid, int size, cpu_set_t cpuset); int sched_setaffinity(int pid, int size, cpu_set_t cpuset); } public static class cpu_set_t extends Structure { private static final int CPUSET_SIZE = 1024; private static final int NCPU_BITS = 8 * NativeLong.SIZE; private static final int SIZE_OF = (CPUSET_SIZE / NCPU_BITS) * NativeLong.SIZE; public NativeLong[] __bits = new NativeLong[CPUSET_SIZE / NCPU_BITS]; public cpu_set_t() { for (int i = 0; i < __bits.length; i++) { __bits[i] = new NativeLong(0); } } public void set(int cpu) { int cIdx = cpu / NCPU_BITS; long mask = 1L << (cpu % NCPU_BITS); NativeLong bit = __bits[cIdx]; bit.setValue(bit.longValue() | mask); } @Override protected List getFieldOrder() { return Collections.singletonList("__bits"); } } } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/IterationScoresFormatter.java000066400000000000000000000056041446271450100335030ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.format.OutputFormat; import java.io.IOException; import java.io.PrintWriter; import java.util.Collection; public class IterationScoresFormatter implements OutputFormat { private final PrintWriter pw; public IterationScoresFormatter(PrintWriter pw) { this.pw = pw; } @Override public void iteration(BenchmarkParams benchParams, IterationParams params, int iteration) { } @Override public void iterationResult(BenchmarkParams benchParams, IterationParams params, int iteration, IterationResult data) { Result r = data.getPrimaryResult(); pw.println(String.format(" %.2f ± %.2f %s", r.getScore(), r.getScoreError(), r.getScoreUnit())); } @Override public void startBenchmark(BenchmarkParams benchParams) { } @Override public void endBenchmark(BenchmarkResult result) { } @Override public void startRun() { } @Override public void endRun(Collection result) { } @Override public void print(String s) { } @Override public void println(String s) { } @Override public void flush() { } @Override public void close() { } @Override public void verbosePrintln(String s) { } @Override public void write(int b) { } @Override public void write(byte[] b) throws IOException { } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java000066400000000000000000000315541446271450100273710ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation; import joptsimple.*; import org.openjdk.jmh.runner.CompilerHints; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.*; import org.openjdk.jmh.util.Utils; import org.openjdk.jmh.util.Version; import org.openjdk.jmh.validation.tests.*; import java.io.IOException; import java.io.PrintWriter; import java.lang.reflect.Field; import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) throws RunnerException, CommandLineOptionException, IOException { PrintWriter pw = new PrintWriter(System.out, true); pw.println("JMH Core Benchmarks, Validation Tests"); pw.println("----------------------------------------------------------------------------------------------------------"); pw.println(); pw.println("# " + Version.getVersion()); pw.println("# " + Utils.getCurrentJvmVersion()); pw.println("# " + Utils.getCurrentOSVersion()); pw.println(); Utils.reflow(pw, "These tests assess the current benchmarking environment health, including hardware, OS, JVM, and JMH " + "itself. While the failure on these tests does not immediately means the problem with environment, " + "it is instructive to understand and follow up on oddities in these tests.", 80, 2); pw.println(); Utils.reflow(pw, "If you are sharing this report, please share it in full, including the JVM version, OS flavor and version, " + "plus some data on used hardware.", 80, 2); pw.println(); pw.println(" Use -h to get help on available options."); pw.println(); OptionParser parser = new OptionParser(); parser.formatHelpWith(new OptionFormatter()); OptionSpec optTests = parser.accepts("t", "Test names.") .withRequiredArg().ofType(Test.class).withValuesSeparatedBy(',').describedAs("string") .defaultsTo(Test.values()); OptionSpec optMode = parser.accepts("m", "Running mode, one of " + Arrays.toString(Mode.values()) + ".") .withRequiredArg().ofType(Mode.class).describedAs("mode") .defaultsTo(Mode.normal); parser.accepts("h", "Print help."); List tests; Mode mode; try { OptionSet set = parser.parse(args); if (set.has("h")) { parser.printHelpOn(System.out); return; } tests = set.valuesOf(optTests); mode = set.valueOf(optMode); } catch (OptionException e) { String message = e.getMessage(); Throwable cause = e.getCause(); if (cause instanceof ValueConversionException) { message += ". " + cause.getMessage(); } throw new CommandLineOptionException(message, e); } Options opts = new OptionsBuilder() .detectJvmArgs() .jvmArgsAppend("-Xmx512m", "-Xms512m", "-server") .build(); switch (mode) { case flash: opts = new OptionsBuilder() .parent(opts) .warmupIterations(3) .warmupTime(TimeValue.milliseconds(10)) .measurementIterations(3) .measurementTime(TimeValue.milliseconds(10)) .forks(1) .build(); break; case quick: opts = new OptionsBuilder() .parent(opts) .warmupIterations(3) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(3) .measurementTime(TimeValue.milliseconds(100)) .forks(3) .build(); break; case normal: opts = new OptionsBuilder() .parent(opts) .warmupIterations(5) .warmupTime(TimeValue.milliseconds(500)) .measurementIterations(5) .measurementTime(TimeValue.milliseconds(500)) .forks(5) .build(); break; case longer: opts = new OptionsBuilder() .parent(opts) .warmupIterations(10) .warmupTime(TimeValue.seconds(1)) .measurementIterations(10) .measurementTime(TimeValue.seconds(1)) .forks(10) .build(); break; default: throw new IllegalStateException(); } for (Test t : tests) { switch (t) { case timing: new TimingMeasurementsTest().runWith(pw, opts); break; case long_stability: switch (mode) { case flash: new LongStabilityTest(3).runWith(pw, opts); break; case quick: new LongStabilityTest(5).runWith(pw, opts); break; case normal: new LongStabilityTest(18).runWith(pw, opts); break; case longer: new LongStabilityTest(60).runWith(pw, opts); break; default: throw new IllegalStateException(); } break; case burst_stability: new BurstStabilityTest().runWith(pw, opts); break; case core_stability: new CoreStabilityTest().runWith(pw, opts); break; case compiler_hints: new CompilerHintsTest().runWith(pw, opts); break; case thermal: switch (mode) { case flash: new ThermalRundownTest(3).runWith(pw, opts); break; case quick: new ThermalRundownTest(5).runWith(pw, opts); break; case normal: new ThermalRundownTest(18).runWith(pw, opts); break; case longer: new ThermalRundownTest(60).runWith(pw, opts); break; default: throw new IllegalStateException(); } break; case helpers: new HelperMethodsTest().runWith(pw, opts); break; case thread_scale: new ThreadScalingTest().runWith(pw, opts); break; case blackhole_cpu: new BlackholeConsumeCPUTest().runWith(pw, opts); break; case blackhole_single: setBlackholeOpts(BlackholeTestMode.normal); new BlackholeSingleTest(BlackholeTestMode.normal).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.compiler); new BlackholeSingleTest(BlackholeTestMode.compiler).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.full_dontinline); new BlackholeSingleTest(BlackholeTestMode.full_dontinline).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.full); new BlackholeSingleTest(BlackholeTestMode.full).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.normal); break; case blackhole_pipelined: setBlackholeOpts(BlackholeTestMode.normal); new BlackholePipelinedTest(false, BlackholeTestMode.normal).runWith(pw, opts); new BlackholePipelinedTest(true, BlackholeTestMode.normal).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.compiler); new BlackholePipelinedTest(false, BlackholeTestMode.compiler).runWith(pw, opts); new BlackholePipelinedTest(true, BlackholeTestMode.compiler).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.full_dontinline); new BlackholePipelinedTest(false, BlackholeTestMode.full_dontinline).runWith(pw, opts); new BlackholePipelinedTest(true, BlackholeTestMode.full_dontinline).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.full); new BlackholePipelinedTest(false, BlackholeTestMode.full).runWith(pw, opts); new BlackholePipelinedTest(true, BlackholeTestMode.full).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.normal); break; case blackhole_consec: setBlackholeOpts(BlackholeTestMode.normal); new BlackholeConsecutiveTest(BlackholeTestMode.normal).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.compiler); new BlackholeConsecutiveTest(BlackholeTestMode.compiler).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.full_dontinline); new BlackholeConsecutiveTest(BlackholeTestMode.full_dontinline).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.full); new BlackholeConsecutiveTest(BlackholeTestMode.full).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.normal); break; case roundtrip_latency: new RoundTripLatencyTest(false).runWith(pw, opts); new RoundTripLatencyTest(true).runWith(pw, opts); break; default: throw new IllegalStateException(); } } } public enum Test { timing, compiler_hints, thermal, long_stability, burst_stability, core_stability, thread_scale, helpers, blackhole_cpu, blackhole_single, blackhole_pipelined, blackhole_consec, roundtrip_latency, } public enum Mode { flash, quick, normal, longer, } private static void setBlackholeOpts(BlackholeTestMode mode) { switch (mode) { case normal: // Do nothing System.getProperties().remove("jmh.blackhole.mode"); break; case compiler: System.getProperties().setProperty("jmh.blackhole.mode", "COMPILER"); break; case full_dontinline: System.getProperties().setProperty("jmh.blackhole.mode", "FULL_DONTINLINE"); break; case full: System.getProperties().setProperty("jmh.blackhole.mode", "FULL"); break; } try { Field f = CompilerHints.class.getDeclaredField("hintsFile"); f.setAccessible(true); f.set(null, null); } catch (Exception e) { throw new IllegalStateException(e); } } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/SpinWaitSupport.java000066400000000000000000000041371446271450100316350ustar00rootroot00000000000000/* * Copyright (c) 2023, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; public class SpinWaitSupport { // All critical code should fold with C2 compilation. // This provides us with JDK 8 compatibility. static final MethodHandle MH; static { MethodHandle mh; try { mh = MethodHandles.lookup().findStatic(Thread.class, "onSpinWait", MethodType.methodType(void.class)); } catch (NoSuchMethodException | IllegalAccessException e) { mh = null; } MH = mh; } public static boolean available() { return MH != null; } public static void onSpinWait() { if (MH != null) { try { MH.invokeExact(); } catch (Throwable e) { throw new IllegalStateException("Should not happen", e); } } } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/ValidationTest.java000066400000000000000000000070541446271450100314350ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.validation.tests.BlackholeTestMode; import java.io.PrintWriter; public abstract class ValidationTest { public abstract void runWith(PrintWriter pw, Options parent) throws RunnerException; protected String blackholeModeString(BlackholeTestMode mode) { switch (mode) { case normal: return "DEFAULT"; case compiler: return "COMPILER BLACKHOLE"; case full_dontinline: return "FULL BLACKHOLE, NO INLINE"; case full: return "FULL BLACKHOLE"; default: throw new IllegalStateException("Unknown blackhole mode: " + mode); } } protected void blackholeModeMessage(PrintWriter pw, BlackholeTestMode mode) { switch (mode) { case normal: break; case compiler: org.openjdk.jmh.util.Utils.reflow(pw, "This particular test mode enables the compiler-assisted blackholes. " + "It should provide the most consistent performance across all types. " + "This mode is only available in modern JDKs.", 80, 2); pw.println(); break; case full_dontinline: org.openjdk.jmh.util.Utils.reflow(pw, "This particular test mode omits the compiler-assisted blackholes. " + "It should provide the basic level of safety for all JDKs.", 80, 2); pw.println(); break; case full: org.openjdk.jmh.util.Utils.reflow(pw, "This particular test mode forces the inline of Blackhole methods, and so demolishes two of the layers " + "in defence in depth. If this layer is broken, Blackhole should also survive. If it isn't, then " + "JMH will have to provide more contingencies.", 80, 2); pw.println(); break; default: throw new IllegalStateException("Unknown blackhole mode: " + mode); } } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/000077500000000000000000000000001446271450100267745ustar00rootroot00000000000000BlackholeConsecutiveTest.java000066400000000000000000000077441446271450100345300ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.benchmarks.BlackholeConsecutiveBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; import java.util.Arrays; public class BlackholeConsecutiveTest extends ValidationTest { private final BlackholeTestMode mode; public BlackholeConsecutiveTest(BlackholeTestMode mode) { this.mode = mode; } @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- BLACKHOLE MERGING TEST (" + blackholeModeString(mode) + ")"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test verifies that calling the Blackhole.consume with the same result is not susceptible for " + "merging. We expect the similar performance across all data types, and the number of consecutive " + "calls. If there are significant differences, this is indicative of Blackhole failure, and it is " + "a serious JMH issue.", 80, 2); pw.println(); blackholeModeMessage(pw, mode); String[] types = new String[] { "boolean", "byte", "short", "char", "int", "float", "long", "double", "Object", }; int[] ss = new int[] {1, 4, 8}; pw.println(" Scores are nanoseconds per Blackhole call."); pw.println(" Trying " + Arrays.toString(ss) + " consecutive Blackhole calls."); pw.println(); pw.printf("%12s", ""); for (int steps : ss) { pw.printf("%20s", steps); } pw.println(); for (String type : types) { pw.printf("%12s", type + ": "); for (int steps : ss) { Options opts = new OptionsBuilder() .parent(parent) .include(BlackholeConsecutiveBench.class.getCanonicalName() + ".test_" + type + "_" + steps) .param("steps", String.valueOf(steps)) .verbosity(VerboseMode.SILENT) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf("%20s", String.format("%.2f ± %.2f", r.getScore() / steps, r.getScoreError() / steps)); pw.flush(); } pw.println(); } pw.println(); } } BlackholeConsumeCPUTest.java000066400000000000000000000064051446271450100342130ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.benchmarks.BlackholeConsumeCPUBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; public class BlackholeConsumeCPUTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- BLACKHOLE CONSUME CPU TEST"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test assesses the Blackhole.consumeCPU performance, that should be linear to " + "the number of tokens. The performance can be slightly different on low token " + "counts. Otherwise, the backoffs with consumeCPU are not reliable. ", 80, 2); pw.println(); pw.println(" Scores are (normalized) nanoseconds per token."); pw.println(); pw.printf("%20s%n", "#Tokens: "); for (int delay : new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 500, 1_000, 5_000, 10_000, 50_000, 100_000, 500_000, 1_000_000, 5_000_000, 10_000_000}) { Options opts = new OptionsBuilder() .parent(parent) .include(BlackholeConsumeCPUBench.class.getCanonicalName()) .verbosity(VerboseMode.SILENT) .param("delay", String.valueOf(delay)) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf("%20s", delay + ": "); pw.flush(); pw.printf("%.2f ± %.2f ns\n", r.getScore() / delay, r.getScoreError() / delay); } pw.println(); } } BlackholePipelinedTest.java000066400000000000000000000107551446271450100341460ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.benchmarks.BlackholePipelineBench; import org.openjdk.jmh.benchmarks.BlackholePipelinePayloadBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; import java.util.Arrays; public class BlackholePipelinedTest extends ValidationTest { private final boolean payload; private final BlackholeTestMode mode; public BlackholePipelinedTest(boolean payload, BlackholeTestMode mode) { this.payload = payload; this.mode = mode; } @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- BLACKHOLE PIPELINED TEST" + (payload ? " + REAL PAYLOAD" : "") + " (" + blackholeModeString(mode) + ")"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test shows the Blackhole performance in a loop with a given number of iterations. We should normally " + "see the uniform numbers across most data types and number of iterations. If the numbers are wildly " + "non-uniform across the number of iteration, this is indicative of Blackhole failure, and may point " + "to a serious JMH issue. Scores are nanoseconds per loop iteration.", 80, 2); pw.println(); if (payload) { pw.println(" Real payload is being injected into the benchmark."); pw.println(); } blackholeModeMessage(pw, mode); String[] types = new String[] { "boolean", "byte", "short", "char", "int", "float", "long", "double", "Object", "Array", }; int[] ss = {1, 10, 100, 1_000, 10_000}; pw.println(" Scores are nanoseconds per (normalized) benchmark op."); pw.println(" Trying loops with " + Arrays.toString(ss) + " iterations."); pw.println(); String canonicalName = (payload ? BlackholePipelinePayloadBench.class : BlackholePipelineBench.class).getCanonicalName(); pw.printf("%12s", ""); for (int steps : ss) { pw.printf("%16s", steps); } pw.println(); for (String type : types) { pw.printf("%12s", type + ": "); for (int steps : ss) { Options opts = new OptionsBuilder() .parent(parent) .include(canonicalName + ".test_" + type) .param("steps", String.valueOf(steps)) .verbosity(VerboseMode.SILENT) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf("%16s", String.format("%.2f ± %.2f", r.getScore() / steps, r.getScoreError() / steps)); pw.flush(); } pw.println(); } pw.println(); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeSingleTest.java000066400000000000000000000073571446271450100335410ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.benchmarks.BlackholeBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; public class BlackholeSingleTest extends ValidationTest { private final BlackholeTestMode mode; public BlackholeSingleTest(BlackholeTestMode mode) { this.mode = mode; } @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- BLACKHOLE SINGLE INVOCATION TEST (" + blackholeModeString(mode) + ")"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test shows the Blackhole overheads, when using a single invocation in the method, " + "whether implicitly via return from @Benchmark, or explicitly via consume(). The performance " + "should be the same for implicit and explicit cases, and comparable across all data types. ", 80, 2); pw.println(); blackholeModeMessage(pw, mode); String[] types = new String[] { "boolean", "byte", "short", "char", "int", "float", "long", "double", "Object", "Array", }; String[] modes = {"implicit", "explicit"}; pw.println(" Scores are nanoseconds per benchmark op."); pw.println(); pw.printf("%20s", ""); for (String mode : modes) { pw.printf("%20s", mode); } pw.println(); for (String type : types) { pw.printf("%20s", type + ": "); for (String impl : modes) { Options opts = new OptionsBuilder() .parent(parent) .include(BlackholeBench.class.getCanonicalName() + "." + impl + "_" + type) .verbosity(VerboseMode.SILENT) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.flush(); pw.printf("%20s", String.format("%.2f ± %.2f ns", r.getScore(), r.getScoreError())); } pw.println(); } pw.println(); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeTestMode.java000066400000000000000000000024551446271450100331760ustar00rootroot00000000000000/* * Copyright (c) 2020, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; public enum BlackholeTestMode { normal, compiler, full_dontinline, full, } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BurstStabilityTest.java000066400000000000000000000075231446271450100334720ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.benchmarks.BurstStabilityBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; public class BurstStabilityTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- BURST STABILITY TEST"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test verifies the performance for a large busy benchmark is the same, regardless " + "of the benchmark mode, and delay before the iteration. The performance should be " + "the same across all delay values, and comparable across different benchmark modes. " + "If there is a significant difference on different delay levels, this is usually " + "indicative of power-saving features enabled, making bursty benchmarks unreliable.", 80, 2); pw.println(); pw.println(" Scores are milliseconds per benchmark operation, or the reciprocal to it."); pw.println(" Delays are injected before each iteration, and are measured in milliseconds."); pw.println(); int[] delays = {0, 1, 10, 100, 1000}; pw.printf("%20s", ""); for (int delay : delays) { pw.printf("%16s", delay); } pw.println(); for (Mode m : Mode.values()) { if (m == Mode.All) continue; Result r = null; pw.printf("%20s", m + ": "); for (int delay : delays) { Options opts = new OptionsBuilder() .parent(parent) .mode(m) .include(BurstStabilityBench.class.getCanonicalName()) .verbosity(VerboseMode.SILENT) .param("delay", String.valueOf(delay)) .build(); RunResult result = new Runner(opts).runSingle(); r = result.getPrimaryResult(); pw.printf("%16s", String.format("%.2f \u00b1 %.2f", r.getScore(), r.getScoreError())); pw.flush(); } pw.println(" " + r.getScoreUnit()); } pw.println(); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/CompilerHintsTest.java000066400000000000000000000104421446271450100332600ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.benchmarks.CompilerHintsBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; public class CompilerHintsTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- COMPILER HINTS TEST"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This tests verifies compiler hints are working as expected. Two baseline tests run the workload " + "in inlined and non-inlined regiments. When the workload is inlined, the optimizations should " + "kill the workload body. Compiler hints should successfully survive in both regiments: " + CompilerControl.Mode.INLINE + " should always inline, and " + CompilerControl.Mode.DONT_INLINE + " " + "should always break inlining. " + CompilerControl.Mode.EXCLUDE + " should be neutral to inlining " + "policy completely.", 80, 2); pw.println(); doWith(parent, pw, "baseI_baseline", "Default inline policy"); doWith(parent, pw, "baseI_inline", " + @" + CompilerControl.class.getSimpleName() + "(" + CompilerControl.Mode.INLINE + ")"); doWith(parent, pw, "baseI_dontInline", " + @" + CompilerControl.class.getSimpleName() + "(" + CompilerControl.Mode.DONT_INLINE + ")"); doWith(parent, pw, "baseI_exclude", " + @" + CompilerControl.class.getSimpleName() + "(" + CompilerControl.Mode.EXCLUDE + ")"); pw.println(); doWith(parent, pw, "baseNI_baseline", "Default no inline policy"); doWith(parent, pw, "baseNI_inline", " + @" + CompilerControl.class.getSimpleName() + "(" + CompilerControl.Mode.INLINE + ")"); doWith(parent, pw, "baseNI_dontInline", " + @" + CompilerControl.class.getSimpleName() + "(" + CompilerControl.Mode.DONT_INLINE + ")"); doWith(parent, pw, "baseNI_exclude", " + @" + CompilerControl.class.getSimpleName() + "(" + CompilerControl.Mode.EXCLUDE + ")"); pw.println(); } private void doWith(Options parent, PrintWriter pw, String test, String descr) throws RunnerException { Options opts = new OptionsBuilder() .parent(parent) .include(CompilerHintsBench.class.getCanonicalName() + "." + test + "$") .verbosity(VerboseMode.SILENT) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf("%50s", descr + ": "); pw.flush(); pw.printf("%.2f \u00b1 %.2f ns\n", r.getScore(), r.getScoreError()); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/CoreStabilityTest.java000066400000000000000000000067601446271450100332650ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.benchmarks.CoreStabilityBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.util.Utils; import org.openjdk.jmh.validation.AffinitySupport; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; import java.util.concurrent.ThreadLocalRandom; public class CoreStabilityTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- CORE STABILITY TEST"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test verifies the performance for a single test by running it on different CPUs. " + "For perfectly symmetric machines, the performance should be the same across all CPUs. " + "If there is a significant difference between the CPUs, this is usually " + "indicative of asymmetric machine, making the benchmarks that do not explicitly control " + "affinity less reliable.", 80, 2); pw.println(); if (!AffinitySupport.isSupported()) { pw.println(" Affinity control is not available on this machine, skipping the test."); pw.println(); return; } int threads = Utils.figureOutHotCPUs(); for (int p = 0; p < threads; p++) { pw.printf(" CPU %3d: ", p); pw.flush(); Options opts = new OptionsBuilder() .parent(parent) .include(CoreStabilityBench.class.getCanonicalName()) .param("p", String.valueOf(p)) .verbosity(VerboseMode.SILENT) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf(" %16s", String.format("%.2f \u00b1 %.2f %s%n", r.getScore(), r.getScoreError(), r.getScoreUnit())); pw.flush(); } } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/HelperMethodsTest.java000066400000000000000000000074571446271450100332570ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.benchmarks.EmptyBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; public class HelperMethodsTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- HELPER METHOD TEST"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "These tests show the overheads of using the benchmark methods. Normally, only " + "Level.Invocation helpers should affect the benchmark performance, since " + "other helpers execute outside the benchmark path.", 80, 2); pw.println(); { Options opts = new OptionsBuilder() .parent(parent) .include(EmptyBench.class.getCanonicalName()) .verbosity(VerboseMode.SILENT) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf("%51s", "running empty benchmark: "); pw.flush(); pw.printf("%.2f \u00b1 %.2f ns\n", r.getScore(), r.getScoreError()); pw.println(); } for (Scope scope : Scope.values()) { for (Level level : Level.values()) { for (String helper : new String[]{"Setup", "TearDown"}) { Options opts = new OptionsBuilder() .parent(parent) .include("Level" + level + "Bench" + "." + scope.name().toLowerCase() + "_" + helper.toLowerCase() + "$") .verbosity(VerboseMode.SILENT) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf("%20s, %16s, %10s: ", "Scope." + scope, "Level." + level, "@" + helper); pw.flush(); pw.printf("%.2f \u00b1 %.2f ns\n", r.getScore(), r.getScoreError()); } } pw.println(); } pw.println(); } }jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/LongStabilityTest.java000066400000000000000000000074741446271450100332770ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.benchmarks.LongStabilityBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; import java.util.concurrent.ThreadLocalRandom; public class LongStabilityTest extends ValidationTest { private final int tries; public LongStabilityTest(int tries) { this.tries = tries; } @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- LONG STABILITY TEST"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test verifies the performance for a single test by running it several times with some " + "delays between the runs. The performance should be the same across all runs. " + "If there is a significant difference between the runs, this is usually " + "indicative of noisy environment, e.g. a busy virtualized node, or background processes " + "interfering with the run, making the benchmarks unreliable.", 80, 2); pw.println(); for (int t = 0; t < tries; t++) { int ms = (t == 0) ? 0 : ThreadLocalRandom.current().nextInt(5_000, 30_000); pw.printf(" Sleeping for %6d ms...", ms); pw.flush(); try { Thread.sleep(ms); } catch (InterruptedException e) { // Do nothing. } pw.print(" Run: "); pw.flush(); Options opts = new OptionsBuilder() .parent(parent) .include(LongStabilityBench.class.getCanonicalName()) .warmupIterations(5) .warmupTime(TimeValue.seconds(1)) .measurementIterations(5) .measurementTime(TimeValue.seconds(1)) .forks(1) .verbosity(VerboseMode.SILENT) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf(" %16s", String.format("%.2f \u00b1 %.2f %s%n", r.getScore(), r.getScoreError(), r.getScoreUnit())); pw.flush(); } } } RoundTripLatencyTest.java000066400000000000000000000121151446271450100336660ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/* * Copyright (c) 2023, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.benchmarks.RoundTripLatencyBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.util.Utils; import org.openjdk.jmh.validation.AffinitySupport; import org.openjdk.jmh.validation.SpinWaitSupport; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; public class RoundTripLatencyTest extends ValidationTest { private boolean spinWaitHints; public RoundTripLatencyTest(boolean spinWaitHints) { this.spinWaitHints = spinWaitHints; } @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- ROUND-TRIP LATENCY TEST" + (spinWaitHints ? " (SPIN-WAIT HINTS)" : "")); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test tries to run latency benchmark across the entire system. " + "For many-core systems, it is normal to see large latency variations between CPU threads pairs. " + "This gives the idea how much the tests with communicating threads would differ when scheduled differently.", 80, 2); pw.println(); pw.println(" Scores are nanoseconds per round-trip."); pw.println(" Axes are CPU numbers as presented by OS."); pw.println(); if (!AffinitySupport.isSupported()) { pw.println(" Affinity control is not available on this machine, skipping the test."); pw.println(); return; } if (spinWaitHints && !SpinWaitSupport.available()) { pw.println(" Spin-wait hints are not supported, skipping the test."); pw.println(); return; } Options basic = new OptionsBuilder() .parent(parent) .include(RoundTripLatencyBench.class.getCanonicalName()) .threads(1) .jvmArgsAppend("-Xms512m", "-Xmx512m", "-XX:+AlwaysPreTouch", "-XX:+UseParallelGC", "-XX:+UseNUMA", "-DspinWait=" + spinWaitHints) .verbosity(VerboseMode.SILENT) .build(); int blockSize = 16; int threads = Utils.figureOutHotCPUs(); int blocks = (threads / blockSize); if (blocks*blockSize < threads) blocks++; for (int pBlock = 0; pBlock < blocks; pBlock++) { int fromP = pBlock*blockSize; int toP = Math.min(threads, (pBlock+1)*blockSize); for (int cBlock = 0; cBlock < blocks; cBlock++) { int fromC = cBlock*blockSize; int toC = Math.min(threads, (cBlock+1)*blockSize); pw.printf("%5s ", ""); for (int c = fromC; c < toC; c++) { pw.printf("%5d:", c); } pw.println(); for (int p = fromP; p < toP; p++) { pw.printf("%5d: ", p); for (int c = fromC; c < toC; c++) { if (p == c) { pw.print(" ----,"); continue; } Options opts = new OptionsBuilder() .parent(basic) .param("p", String.valueOf(p)) .param("c", String.valueOf(c)) .build(); Result r = new Runner(opts).runSingle().getPrimaryResult(); pw.print(String.format("%5.0f,", r.getScore())); pw.flush(); } pw.println(); } pw.println(); } } } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java000066400000000000000000000057141446271450100334570ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.benchmarks.ThermalRundownBench; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.validation.IterationScoresFormatter; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; public class ThermalRundownTest extends ValidationTest { private final int iterations; public ThermalRundownTest(int iterations) { this.iterations = iterations; } @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- THERMAL RUNDOWN TEST"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test tries to heat the machine up, trying to kick in the thermal throttling. If you see the diminishing " + "performance over time, then your system throttles, and many benchmark experiments are unreliable. ", 80, 2); pw.println(); Options opts = new OptionsBuilder() .parent(parent) .include(ThermalRundownBench.class.getCanonicalName()) .warmupIterations(0) .measurementIterations(iterations) .measurementTime(TimeValue.seconds(10)) .threads(Threads.MAX) .forks(1) .verbosity(VerboseMode.SILENT) .build(); new Runner(opts, new IterationScoresFormatter(pw)).runSingle(); pw.println(); } } jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThreadScalingTest.java000066400000000000000000000116241446271450100332130ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.benchmarks.ThreadScalingBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.util.Utils; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; import java.util.SortedSet; import java.util.TreeSet; public class ThreadScalingTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- THREAD SCALING TEST"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test verifies the performance when scaling in multiple threads. " + "In " + Mode.Throughput + " mode, the benchmark should scale almost linearly, at least before " + "the number of physical cores is reached. In other modes, the timings for individual ops should " + "stay roughly the same, at least before the number of physical cores is reached. The departure " + "from the expected behavior might be indicative of scheduling irregularities, power saving " + "features being enabled, process affinity enforced in virtualized environments, etc. -- these may " + "potentially disrupt multi-threaded benchmarks correctness.", 80, 2); pw.println(); pw.println(" Scores are relative to a single-threaded case."); pw.println(" Threads are scaled from 1 to the number of hardware threads."); pw.println(); SortedSet threads = new TreeSet<>(); int max = Utils.figureOutHotCPUs(); for (int t = max; t > 0; t /= 2) { threads.add(t); } threads.add(1); threads.add(2); pw.printf("%20s", ""); for (int delay : threads) { pw.printf("%16s", delay); } pw.println(); for (Mode m : Mode.values()) { if (m == Mode.All) continue; Result r; pw.printf("%20s", m + ": "); double base = 0.0; double baseError = 0.0; for (int t : threads) { Options opts = new OptionsBuilder() .parent(parent) .mode(m) .include(ThreadScalingBench.class.getCanonicalName()) .verbosity(VerboseMode.SILENT) .threads(t) .build(); RunResult result = new Runner(opts).runSingle(); r = result.getPrimaryResult(); double score = r.getScore(); double error = r.getScoreError(); if (t == 1) { base = score; baseError = error; } // https://en.wikipedia.org/wiki/Propagation_of_uncertainty#Simplification // // For f(x, y) = x/y, boldly assuming x and y are independent, // f_err(x, y) = sqrt(x_err^2 + f(x, y)^2 * y_err^2) / y double f = score / base; double f_err = Math.sqrt(Math.pow(error, 2) + Math.pow(f, 2) * Math.pow(baseError, 2)) / base; pw.printf("%16s", String.format("%.2fx \u00b1 %.2fx", f, f_err)); pw.flush(); } pw.println(); } pw.println(); } } TimingMeasurementsTest.java000066400000000000000000000127761446271450100342550ustar00rootroot00000000000000jmh-1.37/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.benchmarks.CurrentTimeMillisTimerBench; import org.openjdk.jmh.benchmarks.EmptyBench; import org.openjdk.jmh.benchmarks.NanoTimerBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.validation.ValidationTest; import java.io.PrintWriter; public class TimingMeasurementsTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- TIMING MEASUREMENTS TEST"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, "This test shows the minimal individual timings possible to measure. " + "This normally affects only SampleTime and SingleShot benchmark modes. " + "Throughput/AverageTime tests can do better since they do only a few " + "timestamps before and after the complete iteration.", 80, 2); pw.println(); doNanoTime(pw, parent, "latency", false); doNanoTime(pw, parent, "latency", true); pw.println(); doCurrentTimeMillis(pw, parent, "latency", false); doCurrentTimeMillis(pw, parent, "latency", true); pw.println(); doNanoTime(pw, parent, "granularity", false); doNanoTime(pw, parent, "granularity", true); pw.println(); doCurrentTimeMillis(pw, parent, "granularity", false); doCurrentTimeMillis(pw, parent, "granularity", true); pw.println(); for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; doEmpty(pw, parent, mode, false); } pw.println(); for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; doEmpty(pw, parent, mode, true); } pw.println(); } private void doEmpty(PrintWriter pw, Options parent, Mode mode, boolean max) throws RunnerException { Options opts = new OptionsBuilder() .parent(parent) .include(EmptyBench.class.getCanonicalName()) .verbosity(VerboseMode.SILENT) .threads(max ? Threads.MAX : 1) .mode(mode) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf("%50s", mode + ", empty benchmark, " + (max ? "max thread" : "one thread") + ": "); pw.flush(); pw.printf("%10.2f \u00b1 %10.2f %s\n", r.getScore(), r.getScoreError(), r.getScoreUnit()); } void doNanoTime(PrintWriter pw, Options parent, String type, boolean max) throws RunnerException { Options opts = new OptionsBuilder() .parent(parent) .include(NanoTimerBench.class.getCanonicalName() + "." + type + "$") .verbosity(VerboseMode.SILENT) .threads(max ? Threads.MAX : 1) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf("%50s", "nanoTime() " + type + ", " + (max ? "max thread" : "one thread") + ": "); pw.flush(); pw.printf("%10.2f \u00b1 %10.2f ns\n", r.getScore(), r.getScoreError()); } void doCurrentTimeMillis(PrintWriter pw, Options parent, String type, boolean max) throws RunnerException { Options opts = new OptionsBuilder() .parent(parent) .include(CurrentTimeMillisTimerBench.class.getCanonicalName() + "." + type + "$") .verbosity(VerboseMode.SILENT) .threads(max ? Threads.MAX : 1) .build(); RunResult result = new Runner(opts).runSingle(); Result r = result.getPrimaryResult(); pw.printf("%50s", "currentTimeMillis() " + type + ", " + (max ? "max thread" : "one thread") + ": "); pw.flush(); pw.printf("%10.2f \u00b1 %10.2f ns\n", r.getScore(), r.getScoreError()); } } jmh-1.37/jmh-core-ct/000077500000000000000000000000001446271450100143365ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/pom.xml000066400000000000000000000142371446271450100156620ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent 1.37 JMH Core Compilation Tests jmh-core-ct jar Oracle http://openjdk.java.net/ 2012 org.openjdk.jmh jmh-core ${project.version} org.openjdk.jmh jmh-generator-annprocess ${project.version} org.openjdk.jmh jmh-generator-reflection ${project.version} org.openjdk.jmh jmh-generator-asm ${project.version} junit junit test UTF-8 com.mycila.maven-license-plugin maven-license-plugin format process-sources
file:///${project.basedir}/../src/license/gpl_cpe/header.txt
true true PHP
org.apache.maven.plugins maven-compiler-plugin -proc:none
${project.build.testSourceDirectory}
default true org.apache.maven.plugins maven-surefire-plugin true -Djmh.ct.generator=annprocess asm org.apache.maven.plugins maven-surefire-plugin true -Djmh.ct.generator=asm reflection org.apache.maven.plugins maven-surefire-plugin true -Djmh.ct.generator=reflection
jmh-1.37/jmh-core-ct/src/000077500000000000000000000000001446271450100151255ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/000077500000000000000000000000001446271450100161045ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/000077500000000000000000000000001446271450100170255ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/UnnamedPackageTest.java000066400000000000000000000030171446271450100233740ustar00rootroot00000000000000/* * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class UnnamedPackageTest { @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(getClass(), "Benchmark class should have package other than default."); } } jmh-1.37/jmh-core-ct/src/test/java/org/000077500000000000000000000000001446271450100176145ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/000077500000000000000000000000001446271450100212465ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/000077500000000000000000000000001446271450100220245ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/000077500000000000000000000000001446271450100224325ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java000066400000000000000000000234501446271450100255310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct; import org.junit.Assert; import org.openjdk.jmh.ct.benchmark.PublicStaticBenchmarkTest; import org.openjdk.jmh.ct.benchmark.PublicSynchronizedStaticBenchmarkStateBenchmarkTest; import org.openjdk.jmh.ct.other.GenericReturnTest; import org.openjdk.jmh.ct.other.SwingTest; import org.openjdk.jmh.generators.asm.ASMGeneratorSource; import org.openjdk.jmh.generators.core.BenchmarkGenerator; import org.openjdk.jmh.generators.core.GeneratorSource; import org.openjdk.jmh.generators.reflection.RFGeneratorSource; import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.JDKVersion; import org.openjdk.jmh.util.Utils; import javax.tools.*; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URI; import java.util.*; public class CompileTest { private static final String GENERATOR_TYPE = System.getProperty("jmh.ct.generator", "notset"); private static final String SRC_PREFIX = "SRC: "; public static void assertFail(Class klass) { InMemoryGeneratorDestination destination = new InMemoryGeneratorDestination(); boolean success = doTest(klass, destination); if (success) { Assert.fail("Should have failed."); } } public static void assertFail(Class klass, String error) { InMemoryGeneratorDestination destination = new InMemoryGeneratorDestination(); boolean success = doTest(klass, destination); if (success) { Assert.fail("Should have failed."); } List testErrors = new ArrayList<>(); boolean contains = false; for (String e : destination.getErrors()) { if (!e.startsWith(SRC_PREFIX)) { testErrors.add(e); contains |= e.contains(error); } System.err.println(e); } Assert.assertTrue("Failure message should contain \"" + error + "\", but was \"" + testErrors + "\"", contains); } public static void assertOK(Class klass) { InMemoryGeneratorDestination destination = new InMemoryGeneratorDestination(); boolean success = doTest(klass, destination); if (!success) { for (String e : destination.getErrors()) { System.err.println(e); } Assert.fail("Should have passed."); } } private static boolean doTest(Class klass, InMemoryGeneratorDestination destination) { if (GENERATOR_TYPE.equalsIgnoreCase("reflection")) { RFGeneratorSource source = new RFGeneratorSource(); source.processClasses(klass); return doTestOther(klass, source, destination); } else if (GENERATOR_TYPE.equalsIgnoreCase("asm")) { ASMGeneratorSource source = new ASMGeneratorSource(); String name = "/" + klass.getCanonicalName().replaceAll("\\.", "/") + ".class"; try { source.processClass(klass.getResourceAsStream(name)); } catch (IOException e) { throw new IllegalStateException(name, e); } return doTestOther(klass, source, destination); } else if (GENERATOR_TYPE.equalsIgnoreCase("annprocess")) { return doTestAnnprocess(klass, destination); } else throw new IllegalStateException("Unhandled compile test generator: " + GENERATOR_TYPE); } private static Collection javacOptions(boolean annProc, Class klass) { Collection result = new ArrayList<>(); if (!annProc) { result.add("-proc:none"); } // These tests print warnings (as designed), so -Werror fails. boolean noWerror = klass.equals(SwingTest.class); if (!noWerror) { result.add("-Werror"); } // These tests fail when generated code references the static target // through the instance. boolean noStatic = klass.equals(GenericReturnTest.class) || klass.equals(PublicStaticBenchmarkTest.class) || klass.equals(PublicSynchronizedStaticBenchmarkStateBenchmarkTest.class); // JDK 17 introduces a new warning about unnecessary strictfp use. boolean noStrictFPChecks = JDKVersion.parseMajor(System.getProperty("java.version")) >= 17; result.add("-Xlint:all" + (annProc ? ",-processing" : "") + (noStatic ? ",-static" : "") + (noStrictFPChecks ? ",-strictfp" : "")); return result; } public static boolean doTestOther(Class klass, GeneratorSource source, InMemoryGeneratorDestination destination) { BenchmarkGenerator gen = new BenchmarkGenerator(); gen.generate(source, destination); gen.complete(source, destination); if (destination.hasErrors()) { return false; } DiagnosticCollector diagnostics = new DiagnosticCollector<>(); JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); setupClassOutput(fm); Collection sources = new ArrayList<>(); for (Map.Entry e : destination.getClasses().entrySet()) { sources.add(new JavaSourceFromString(e.getKey(), e.getValue())); } JavaCompiler.CompilationTask task = javac.getTask(null, fm, diagnostics, javacOptions(false, klass), null, sources); boolean success = task.call(); if (!success) { for (JavaSourceFromString src : sources) { destination.printError(SRC_PREFIX + src.getCharContent(false).toString()); } for (Diagnostic diagnostic : diagnostics.getDiagnostics()) { destination.printError(diagnostic.getKind() + " at line " + diagnostic.getLineNumber() + ": " + diagnostic.getMessage(null)); } } return success; } private static boolean doTestAnnprocess(Class klass, InMemoryGeneratorDestination destination) { DiagnosticCollector diagnostics = new DiagnosticCollector<>(); JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); setupClassOutput(fm); String name = "/" + klass.getCanonicalName().replaceAll("\\.", "/") + ".java"; String shortName = klass.getName(); InputStream stream = klass.getResourceAsStream(name); Assert.assertNotNull(name + " is not found", stream); try { Collection lines = FileUtils.readAllLines(new InputStreamReader(stream)); String file = Utils.join(lines, "\n"); Collection sources = Collections.singleton(new JavaSourceFromString(shortName, file)); JavaCompiler.CompilationTask task = javac.getTask(null, fm, diagnostics, javacOptions(true, klass), null, sources); boolean success = task.call(); if (!success) { for (JavaSourceFromString src : sources) { destination.printError(SRC_PREFIX + src.getCharContent(false).toString()); } for (Diagnostic diagnostic : diagnostics.getDiagnostics()) { destination.printError(diagnostic.getKind() + " at line " + diagnostic.getLineNumber() + ": " + diagnostic.getMessage(null)); } } return success; } catch (IOException e) { return false; } } private static void setupClassOutput(StandardJavaFileManager fm) { try { File tmp = File.createTempFile("jmh-core-ct", "temp"); if (!tmp.delete()) { throw new IOException("Cannot delete temp file: " + tmp); } if (!tmp.mkdirs()) { throw new IOException("Cannot create temp dir: " + tmp); } tmp.deleteOnExit(); fm.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(tmp)); } catch (IOException e) { Assert.fail(e.getMessage()); } } public static class JavaSourceFromString extends SimpleJavaFileObject { final String code; JavaSourceFromString(String name, String code) { super(URI.create("string:///" + name.replace('.', '/') + JavaFileObject.Kind.SOURCE.extension), JavaFileObject.Kind.SOURCE); this.code = code; } @Override public CharSequence getCharContent(boolean iee) { return code; } } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java000066400000000000000000000110601446271450100311030ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct; import org.openjdk.jmh.generators.core.GeneratorDestination; import org.openjdk.jmh.generators.core.MetadataInfo; import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class InMemoryGeneratorDestination implements GeneratorDestination { private final List errors = new ArrayList<>(); private final List warnings = new ArrayList<>(); private final List infos = new ArrayList<>(); private final Map classBodies = new HashMap<>(); private final Map resourceBodies = new HashMap<>(); @Override public OutputStream newResource(String resourcePath) throws IOException { ByteArrayOutputStream sw = new ByteArrayOutputStream(); resourceBodies.put(resourcePath, sw); return sw; } @Override public InputStream getResource(String resourcePath) throws IOException { ByteArrayOutputStream sw = resourceBodies.get(resourcePath); if (sw == null) { throw new IOException("Does not exist: " + resourcePath); } return new ByteArrayInputStream(sw.toByteArray()); } @Override public Writer newClass(String className, String originatingClassName) throws IOException { StringWriter sw = new StringWriter(); classBodies.put(className, sw); return new PrintWriter(sw, true); } @Override public void printError(String message) { errors.add(message); } @Override public void printError(String message, MetadataInfo element) { errors.add(message); } @Override public void printError(String message, Throwable throwable) { errors.add(message + ":\n" + throwable.toString()); } public boolean hasErrors() { return !errors.isEmpty(); } public List getErrors() { return errors; } @Override public void printWarning(String message) { warnings.add(message); } @Override public void printWarning(String message, MetadataInfo element) { warnings.add(message); } @Override public void printWarning(String message, Throwable throwable) { warnings.add(message + ":\n" + throwable.toString()); } public boolean hasWarnings() { return !warnings.isEmpty(); } public List getWarnings() { return warnings; } public Map getClasses() { Map result = new HashMap<>(); for (Map.Entry e : classBodies.entrySet()) { result.put(e.getKey(), e.getValue().toString()); } return result; } public Map getResources() { Map result = new HashMap<>(); for (Map.Entry e : resourceBodies.entrySet()) { try { result.put(e.getKey(), e.getValue().toString("UTF-8")); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } } return result; } @Override public void printNote(String message) { infos.add(message); } public boolean hasNotes() { return !infos.isEmpty(); } public List getNotes() { return infos; } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/000077500000000000000000000000001446271450100243645ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/BenchmarkTest.java000066400000000000000000000027741446271450100277730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class BenchmarkTest { @Benchmark void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/PublicAbstractBenchmarkTest.java000066400000000000000000000030331446271450100326030ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public abstract class PublicAbstractBenchmarkTest { @Benchmark public abstract void test(); @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/PublicBenchmarkTest.java000066400000000000000000000030071446271450100311200ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PublicBenchmarkTest { @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/PublicStaticBenchmarkTest.java000066400000000000000000000030241446271450100322670ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PublicStaticBenchmarkTest { @Benchmark public static void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/PublicSynchronizedBenchmarkTest.java000066400000000000000000000030421446271450100335170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PublicSynchronizedBenchmarkTest { @Benchmark public synchronized void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } PublicSynchronizedStateBenchmarkTest.java000066400000000000000000000032211446271450100344400ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class PublicSynchronizedStateBenchmarkTest { @Benchmark public synchronized void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } PublicSynchronizedStaticBenchmarkStateBenchmarkTest.java000066400000000000000000000032471446271450100374330ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class PublicSynchronizedStaticBenchmarkStateBenchmarkTest { @Benchmark public static synchronized void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } PublicSynchronizedStaticBenchmarkTest.java000066400000000000000000000031331446271450100346110ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PublicSynchronizedStaticBenchmarkTest { @Benchmark public static synchronized void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "enclosing class is annotated with @State"); } } PublicSynchronizedStaticThreadStateBenchmarkTest.java000066400000000000000000000032761446271450100367520ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Thread) public class PublicSynchronizedStaticThreadStateBenchmarkTest { @Benchmark public static synchronized void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "@State(Scope.Benchmark)"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/000077500000000000000000000000001446271450100253205ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/ArgumentListAmbiguityTest.java000066400000000000000000000032211446271450100333120ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class ArgumentListAmbiguityTest { @Benchmark public void test() { } @Benchmark public void test(Blackhole bh) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "uniquely named method"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/BenchmarkParamsTest.java000066400000000000000000000031311446271450100320570ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.BenchmarkParams; public class BenchmarkParamsTest { @Benchmark public void test(BenchmarkParams benchmarkParams) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/BlackholeTest.java000066400000000000000000000030721446271450100307110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class BlackholeTest { @Benchmark public void test(Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/ControlTest.java000066400000000000000000000030651446271450100304470ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Control; public class ControlTest { @Benchmark public void test(Control cnt) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/IterationParamsTest.java000066400000000000000000000031201446271450100321210ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.IterationParams; public class IterationParamsTest { @Benchmark public void test(IterationParams params) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/NoStateTest.java000066400000000000000000000030471446271450100304040ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class NoStateTest { public static class S {} @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/ObjectArrayTest.java000066400000000000000000000030271446271450100312320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class ObjectArrayTest { @Benchmark public void test(Object[] args) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/ObjectTest.java000066400000000000000000000030201446271450100302240ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class ObjectTest { @Benchmark public void test(Object args) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/StateTest.java000066400000000000000000000032231446271450100301030ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class StateTest { @State(Scope.Benchmark) public static class S {} @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/StringArrayTest.java000066400000000000000000000030271446271450100312720ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class StringArrayTest { @Benchmark public void test(String[] args) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/StringTest.java000066400000000000000000000030201446271450100302640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class StringTest { @Benchmark public void test(String args) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/000077500000000000000000000000001446271450100264525ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimBooleanArrayTest.java000066400000000000000000000030771446271450100333720ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimBooleanArrayTest { @Benchmark public void test(boolean[] v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimBooleanTest.java000066400000000000000000000030701446271450100323640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimBooleanTest { @Benchmark public void test(boolean v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimByteArrayTest.java000066400000000000000000000030711446271450100327100ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimByteArrayTest { @Benchmark public void test(byte[] v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimByteTest.java000066400000000000000000000030621446271450100317110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimByteTest { @Benchmark public void test(byte v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimCharArrayTest.java000066400000000000000000000030711446271450100326620ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimCharArrayTest { @Benchmark public void test(char[] v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimCharTest.java000066400000000000000000000030621446271450100316630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimCharTest { @Benchmark public void test(char v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimDoubleArrayTest.java000066400000000000000000000030751446271450100332230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimDoubleArrayTest { @Benchmark public void test(double[] v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimDoubleTest.java000066400000000000000000000030661446271450100322240ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimDoubleTest { @Benchmark public void test(double v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimFloatArrayTest.java000066400000000000000000000030731446271450100330540ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimFloatArrayTest { @Benchmark public void test(float[] v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimFloatTest.java000066400000000000000000000030641446271450100320550ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimFloatTest { @Benchmark public void test(float v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimIntArrayTest.java000066400000000000000000000030671446271450100325440ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimIntArrayTest { @Benchmark public void test(int[] v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimIntTest.java000066400000000000000000000030601446271450100315360ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimIntTest { @Benchmark public void test(int v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimLongArrayTest.java000066400000000000000000000030711446271450100327040ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimLongArrayTest { @Benchmark public void test(long[] v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimLongTest.java000066400000000000000000000030621446271450100317050ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimLongTest { @Benchmark public void test(long v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimShortArrayTest.java000066400000000000000000000030731446271450100331060ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimShortArrayTest { @Benchmark public void test(short[] v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/benchmark/args/prims/PrimShortTest.java000066400000000000000000000030641446271450100321070ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.benchmark.args.prims; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class PrimShortTest { @Benchmark public void test(short v) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/blackhole/000077500000000000000000000000001446271450100243565ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/blackhole/BlackholeTypesTest.java000066400000000000000000000070441446271450100307770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.blackhole; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; @State(Scope.Thread) @BenchmarkMode(Mode.All) public class BlackholeTypesTest { public byte b; public boolean bool; public char c; public short s; public int i; public long l; public float f; public double d; public Object o; public Object[] os; @Benchmark public void baseline() { // do nothing } @Benchmark public byte implicit_testByte() { return b; } @Benchmark public boolean implicit_testBoolean() { return bool; } @Benchmark public char implicit_testChar() { return c; } @Benchmark public int implicit_testInt() { return i; } @Benchmark public long implicit_testLong() { return l; } @Benchmark public float implicit_testFloat() { return f; } @Benchmark public double implicit_testDouble() { return d; } @Benchmark public Object implicit_testObject() { return o; } @Benchmark public Object[] implicit_testArray() { return os; } @Benchmark public void explicit_testByte(Blackhole bh) { bh.consume(b); } @Benchmark public void explicit_testBoolean(Blackhole bh) { bh.consume(bool); } @Benchmark public void explicit_testChar(Blackhole bh) { bh.consume(c); } @Benchmark public void explicit_testInt(Blackhole bh) { bh.consume(i); } @Benchmark public void explicit_testLong(Blackhole bh) { bh.consume(l); } @Benchmark public void explicit_testFloat(Blackhole bh) { bh.consume(f); } @Benchmark public void explicit_testDouble(Blackhole bh) { bh.consume(d); } @Benchmark public void explicit_testObject(Blackhole bh) { bh.consume(o); } @Benchmark public void explicit_testArray(Blackhole bh) { bh.consume(os); } @Test public void test() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/collisions/000077500000000000000000000000001446271450100246105ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/collisions/CollisionTest.java000066400000000000000000000035601446271450100302520ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.collisions; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class CollisionTest { @Benchmark @Group("same") @Warmup(iterations = 1) public void g1() { } @Benchmark @Group("same") @Warmup(iterations = 5) public void g2() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Colliding annotations"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/collisions/NoCollisionTest.java000066400000000000000000000035271446271450100305520ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.collisions; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class NoCollisionTest { @Benchmark @Group("same") @Warmup(iterations = 1) public void g1() { } @Benchmark @Group("same") @Warmup(iterations = 1) public void g2() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/collisions/SuperCollisionTest.java000066400000000000000000000036321446271450100312710ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.collisions; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.ct.CompileTest; @Warmup(iterations = 1) @BenchmarkMode(Mode.All) public class SuperCollisionTest { @Benchmark @Group("same") // inherited @Warmup(iterations = 1) public void g1() { } @Benchmark @Group("same") @Warmup(iterations = 5) public void g2() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Colliding annotations"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/collisions/SuperNoCollisionTest.java000066400000000000000000000035641446271450100315720ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.collisions; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.ct.CompileTest; @Warmup(iterations = 1) @BenchmarkMode(Mode.All) public class SuperNoCollisionTest { @Benchmark @Group("same") @Warmup(iterations = 1) public void g1() { } @Benchmark @Group("same") @Warmup(iterations = 1) public void g2() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/exceptions/000077500000000000000000000000001446271450100246135ustar00rootroot00000000000000BenchmarkBenchExceptionSignaturesTest.java000066400000000000000000000045161446271450100350230ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/exceptions/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.exceptions; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) @BenchmarkMode(Mode.All) public class BenchmarkBenchExceptionSignaturesTest { @Setup(Level.Trial) public void setup1() throws Exception {} @Setup(Level.Iteration) public void setup2() throws Exception {} @Setup(Level.Invocation) public void setup3() throws Exception {} @TearDown(Level.Trial) public void tearDown1() throws Exception {} @TearDown(Level.Iteration) public void tearDown2() throws Exception {} @TearDown(Level.Invocation) public void tearDown3() throws Exception {} @Benchmark public void test() throws Exception {} @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } BenchmarkStateExceptionSignaturesTest.java000066400000000000000000000047571446271450100350730ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/exceptions/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.exceptions; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class BenchmarkStateExceptionSignaturesTest { @State(Scope.Benchmark) public static class MyState { @Setup(Level.Trial) public void setup1() throws Exception { } @Setup(Level.Iteration) public void setup2() throws Exception { } @Setup(Level.Invocation) public void setup3() throws Exception { } @TearDown(Level.Trial) public void tearDown1() throws Exception { } @TearDown(Level.Iteration) public void tearDown2() throws Exception { } @TearDown(Level.Invocation) public void tearDown3() throws Exception { } } @Benchmark public void test(MyState s) throws Exception { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } GroupBenchExceptionSignaturesTest.java000066400000000000000000000046001446271450100342170ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/exceptions/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.exceptions; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) @State(Scope.Group) public class GroupBenchExceptionSignaturesTest { @Setup(Level.Trial) public void setup1() throws Exception {} @Setup(Level.Iteration) public void setup2() throws Exception {} @Setup(Level.Invocation) public void setup3() throws Exception {} @TearDown(Level.Trial) public void tearDown1() throws Exception {} @TearDown(Level.Iteration) public void tearDown2() throws Exception {} @TearDown(Level.Invocation) public void tearDown3() throws Exception {} @Benchmark @Group("T") public void test() throws Exception {} @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } GroupStateExceptionSignaturesTest.java000066400000000000000000000050411446271450100342600ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/exceptions/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.exceptions; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class GroupStateExceptionSignaturesTest { @State(Scope.Group) public static class MyState { @Setup(Level.Trial) public void setup1() throws Exception { } @Setup(Level.Iteration) public void setup2() throws Exception { } @Setup(Level.Invocation) public void setup3() throws Exception { } @TearDown(Level.Trial) public void tearDown1() throws Exception { } @TearDown(Level.Iteration) public void tearDown2() throws Exception { } @TearDown(Level.Invocation) public void tearDown3() throws Exception { } } @Benchmark @Group("T") public void test(MyState s) throws Exception { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } ThreadBenchExceptionSignaturesTest.java000066400000000000000000000045101446271450100343320ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/exceptions/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.exceptions; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) @State(Scope.Thread) public class ThreadBenchExceptionSignaturesTest { @Setup(Level.Trial) public void setup1() throws Exception {} @Setup(Level.Iteration) public void setup2() throws Exception {} @Setup(Level.Invocation) public void setup3() throws Exception {} @TearDown(Level.Trial) public void tearDown1() throws Exception {} @TearDown(Level.Iteration) public void tearDown2() throws Exception {} @TearDown(Level.Invocation) public void tearDown3() throws Exception {} @Benchmark public void test() throws Exception {} @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } ThreadStateExceptionSignaturesTest.java000066400000000000000000000047511446271450100344020ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/exceptions/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.exceptions; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class ThreadStateExceptionSignaturesTest { @State(Scope.Thread) public static class MyState { @Setup(Level.Trial) public void setup1() throws Exception { } @Setup(Level.Iteration) public void setup2() throws Exception { } @Setup(Level.Invocation) public void setup3() throws Exception { } @TearDown(Level.Trial) public void tearDown1() throws Exception { } @TearDown(Level.Iteration) public void tearDown2() throws Exception { } @TearDown(Level.Invocation) public void tearDown3() throws Exception { } } @Benchmark public void test(MyState s) throws Exception { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/000077500000000000000000000000001446271450100250175ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/Benchmark1.java000066400000000000000000000025341446271450100276410ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.multsession; import org.openjdk.jmh.annotations.Benchmark; public class Benchmark1 { @Benchmark public void test() {} } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/Benchmark2.java000066400000000000000000000025341446271450100276420ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.multsession; import org.openjdk.jmh.annotations.Benchmark; public class Benchmark2 { @Benchmark public void test() {} } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/MultipleSessionsTest.java000066400000000000000000000113641446271450100320510ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.multsession; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.ct.InMemoryGeneratorDestination; import org.openjdk.jmh.generators.core.BenchmarkGenerator; import org.openjdk.jmh.generators.reflection.RFGeneratorSource; import org.openjdk.jmh.runner.BenchmarkList; public class MultipleSessionsTest { @Test public void testAppend() { InMemoryGeneratorDestination dst = new InMemoryGeneratorDestination(); { RFGeneratorSource src = new RFGeneratorSource(); BenchmarkGenerator gen = new BenchmarkGenerator(); src.processClasses(Benchmark1.class); gen.generate(src, dst); gen.complete(src, dst); Assert.assertFalse("First stage error", dst.hasErrors()); Assert.assertFalse("First stage warnings", dst.hasWarnings()); Assert.assertFalse("First stage infos", dst.hasNotes()); String[] list = dst.getResources().get(BenchmarkList.BENCHMARK_LIST.substring(1)).split("\n"); Assert.assertEquals("First stage should have only 1 benchmark", 1, list.length); } { RFGeneratorSource src = new RFGeneratorSource(); BenchmarkGenerator gen = new BenchmarkGenerator(); src.processClasses(Benchmark2.class); gen.generate(src, dst); gen.complete(src, dst); Assert.assertFalse("Second stage error", dst.hasErrors()); Assert.assertFalse("Second stage warnings", dst.hasWarnings()); Assert.assertFalse("Second stage notes", dst.hasNotes()); String[] list = dst.getResources().get(BenchmarkList.BENCHMARK_LIST.substring(1)).split("\n"); Assert.assertEquals("Second stage should have 2 benchmarks", 2, list.length); } } @Test public void testOverwrite() { InMemoryGeneratorDestination dst = new InMemoryGeneratorDestination(); { RFGeneratorSource src = new RFGeneratorSource(); BenchmarkGenerator gen = new BenchmarkGenerator(); src.processClasses(Benchmark1.class); gen.generate(src, dst); gen.complete(src, dst); Assert.assertFalse("First stage error", dst.hasErrors()); Assert.assertFalse("First stage warnings", dst.hasWarnings()); Assert.assertFalse("First stage notes", dst.hasNotes()); String[] list = dst.getResources().get(BenchmarkList.BENCHMARK_LIST.substring(1)).split("\n"); Assert.assertEquals("First stage should have only 1 benchmark", 1, list.length); } { RFGeneratorSource src = new RFGeneratorSource(); BenchmarkGenerator gen = new BenchmarkGenerator(); src.processClasses(Benchmark1.class); gen.generate(src, dst); gen.complete(src, dst); Assert.assertFalse("Second stage error", dst.hasErrors()); Assert.assertFalse("Second stage warnings", dst.hasWarnings()); Assert.assertTrue("Second stage notes", dst.hasNotes()); boolean hasOurInfo = false; for (String warning : dst.getNotes()) { hasOurInfo |= (warning.contains("Benchmark1") && warning.contains("overwriting")); } Assert.assertTrue("Should have our note: " + dst.getNotes(), hasOurInfo); String[] list = dst.getResources().get(BenchmarkList.BENCHMARK_LIST.substring(1)).split("\n"); Assert.assertEquals("Second stage should have 1 benchmark", 1, list.length); } } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/000077500000000000000000000000001446271450100235535ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/BlackholeApiTest.java000066400000000000000000000041331446271450100275750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; /** * Tests basic blackholing API. */ @BenchmarkMode(Mode.All) public class BlackholeApiTest { @Benchmark public void testNothing() { } @Benchmark public Object testReturnObject() { return null; } @Benchmark public int testReturnInt() { return 0; } @Benchmark public void testBH(Blackhole bh) { } @Benchmark public Object testBH_ReturnObject(Blackhole bh) { return null; } @Benchmark public int testBH_ReturnInt(Blackhole bh) { return 0; } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/ControlTest.java000066400000000000000000000056611446271450100267060ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Control; public class ControlTest { @State(Scope.Benchmark) public static class BenchmarkState { } @State(Scope.Thread) public static class ThreadState { } @State(Scope.Group) public static class GroupState { } @Benchmark @Group("plain") public void plain_test1(Control cnt) { } @Benchmark @Group("plain") public void plain_test2(Control cnt) { } @Benchmark @Group("plain") public void plain_test3() { } @Benchmark @Group("bench") public void bench_test1(BenchmarkState s, Control cnt) { } @Benchmark @Group("bench") public void bench_test2(BenchmarkState s, Control cnt) { } @Benchmark @Group("bench") public void bench_test3(BenchmarkState s) { } @Benchmark @Group("thread") public void thread_test1(ThreadState s, Control cnt) { } @Benchmark @Group("thread") public void thread_test2(ThreadState s, Control cnt) { } @Benchmark @Group("thread") public void thread_test3(ThreadState s) { } @Benchmark @Group("group") public void group_test1(GroupState s, Control cnt) { } @Benchmark @Group("group") public void group_test2(GroupState s, Control cnt) { } @Benchmark @Group("group") public void group_test3(GroupState s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/GenericParamTest.java000066400000000000000000000031061446271450100276130ustar00rootroot00000000000000/* * Copyright (c) 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class GenericParamTest { @Benchmark public static Object test(E param) { return null; } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Method parameters should be either @State classes"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/GenericReturnTest.java000066400000000000000000000030041446271450100300270ustar00rootroot00000000000000/* * Copyright (c) 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class GenericReturnTest { @Benchmark public static E test() { return null; } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/JmhNameTest.java000066400000000000000000000031671446271450100266040ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class JmhNameTest { @Benchmark public void jmh() { // Intentionally left blank } @Benchmark public void jmhNameTest() { // Intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/MeasureTest.java000066400000000000000000000046611446271450100266660ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.ct.CompileTest; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) public class MeasureTest { @Benchmark @Measurement(iterations = 2) public void test1() { } @Benchmark @Measurement(time = 3) public void test2() { } @Benchmark @Measurement(timeUnit = TimeUnit.MICROSECONDS) public void test3() { } @Benchmark @Measurement(batchSize = 7) public void test4() { } @Benchmark @Measurement(iterations = 2, time = 3) public void test5() { } @Benchmark @Measurement(iterations = 2, time = 3, timeUnit = TimeUnit.MICROSECONDS) public void test6() { } @Benchmark @Measurement(iterations = 2, batchSize = 7) public void test7() { } @Benchmark @Measurement(iterations = 2, time = 3, timeUnit = TimeUnit.MICROSECONDS, batchSize = 7) public void test8() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/MultipleBenchmarkStateTest.java000066400000000000000000000040121446271450100316620ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class MultipleBenchmarkStateTest { @State(Scope.Benchmark) public static class G1 {} @State(Scope.Benchmark) public static class G2 {} @State(Scope.Benchmark) public static class G3 {} @Benchmark public void test1(G1 g1) { } @Benchmark public void test2(G1 g1, G2 g2) { } @Benchmark public void test3(G1 g1, G2 g2, G3 g3) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/MultipleExecGroupStateTest.java000066400000000000000000000041441446271450100316770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class MultipleExecGroupStateTest { @State(Scope.Group) public static class G1 {} @State(Scope.Group) public static class G2 {} @State(Scope.Group) public static class G3 {} @Benchmark @Group("group") public void test1(G1 g1) { } @Benchmark @Group("group") public void test2(G1 g1, G2 g2) { } @Benchmark @Group("group") public void test3(G1 g1, G2 g2, G3 g3) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/MultipleGroupStateTest.java000066400000000000000000000041241446271450100310700ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class MultipleGroupStateTest { @State(Scope.Group) public static class G1 {} @State(Scope.Group) public static class G2 {} @State(Scope.Group) public static class G3 {} @Benchmark @Group("T") public void test1(G1 g1) { } @Benchmark @Group("T") public void test2(G1 g1, G2 g2) { } @Benchmark @Group("T") public void test3(G1 g1, G2 g2, G3 g3) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/MultipleThreadStateTest.java000066400000000000000000000037761446271450100312170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class MultipleThreadStateTest { @State(Scope.Thread) public static class G1 {} @State(Scope.Thread) public static class G2 {} @State(Scope.Thread) public static class G3 {} @Benchmark public void test1(G1 g1) { } @Benchmark public void test2(G1 g1, G2 g2) { } @Benchmark public void test3(G1 g1, G2 g2, G3 g3) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/OperationsPerInvocationTest.java000066400000000000000000000036171446271450100321110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OperationsPerInvocation; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class OperationsPerInvocationTest { @Benchmark @OperationsPerInvocation(1) public void test1() { } @Benchmark @OperationsPerInvocation(10) public void test2() { } @Benchmark @OperationsPerInvocation(Integer.MAX_VALUE) public void test3() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/SameBasenameStateTest.java000066400000000000000000000036241446271450100306050ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class SameBasenameStateTest { public static class Enclosure1 { @State(Scope.Thread) public static class S { } } public static class Enclosure2 { @State(Scope.Thread) public static class S { } } @Benchmark public void work(Enclosure1.S s1, Enclosure2.S s2) { // this method was intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/StrictFPClassTest.java000066400000000000000000000032341446271450100277440ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public strictfp class StrictFPClassTest { @Benchmark public void test() { // intentionally blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/StrictFPMethodTest.java000066400000000000000000000032351446271450100301200ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.ct.CompileTest; @BenchmarkMode(Mode.All) public class StrictFPMethodTest { @Benchmark public strictfp void test() { // intentionally blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/SwingTest.java000066400000000000000000000031031446271450100263420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; import javax.swing.*; public class SwingTest { public static class S extends JFrame { } @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/WarmupTest.java000066400000000000000000000046031446271450100265340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.ct.CompileTest; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) public class WarmupTest { @Benchmark @Warmup(iterations = 2) public void test1() { } @Benchmark @Warmup(time = 3) public void test2() { } @Benchmark @Warmup(timeUnit = TimeUnit.MICROSECONDS) public void test3() { } @Benchmark @Warmup(batchSize = 7) public void test4() { } @Benchmark @Warmup(iterations = 2, time = 3) public void test5() { } @Benchmark @Warmup(iterations = 2, time = 3, timeUnit = TimeUnit.MICROSECONDS) public void test6() { } @Benchmark @Warmup(iterations = 2, batchSize = 7) public void test7() { } @Benchmark @Warmup(iterations = 2, time = 3, timeUnit = TimeUnit.MICROSECONDS, batchSize = 7) public void test8() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/000077500000000000000000000000001446271450100261335ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/AuxCountersTest.java000066400000000000000000000044321446271450100321210ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class AuxCountersTest { @State(Scope.Benchmark) public static class BenchmarkState { public int x; } @State(Scope.Group) public static class GroupState { public int y; } @AuxCounters @State(Scope.Thread) public static class ThreadState { public int z; } @Benchmark public void testThread(ThreadState s) { } @Benchmark @Group("test_gt") public void testGroupThread_1(GroupState gs, ThreadState ts) { } @Benchmark @Group("test_gt") public void testGroupThread_2(GroupState gs, ThreadState ts) { } @Benchmark public void testBenchThread(BenchmarkState bs, ThreadState ts) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/HelperConflictTest.java000066400000000000000000000040421446271450100325370ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class HelperConflictTest { @AuxCounters @State(Scope.Thread) public static class S { @Setup(Level.Trial) public void setupTrial() {} @Setup(Level.Iteration) public void setupIteration() {} @Setup(Level.Invocation) public void setupInvocation() {} @TearDown(Level.Invocation) public void tearDownInvocation() {} @TearDown(Level.Iteration) public void tearDownIteration() {} @TearDown(Level.Trial) public void tearDownTrial() {} } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/000077500000000000000000000000001446271450100306375ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/000077500000000000000000000000001446271450100334405ustar00rootroot00000000000000BooleanTest.java000066400000000000000000000034341446271450100364470ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class BooleanTest { @AuxCounters @State(Scope.Thread) public static class S { boolean cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } ByteTest.java000066400000000000000000000034261446271450100357740ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ByteTest { @AuxCounters @State(Scope.Thread) public static class S { byte cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } CharTest.java000066400000000000000000000034261446271450100357460ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class CharTest { @AuxCounters @State(Scope.Thread) public static class S { char cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } DoubleTest.java000066400000000000000000000034321446271450100363000ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class DoubleTest { @AuxCounters @State(Scope.Thread) public static class S { double cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } FloatTest.java000066400000000000000000000034301446271450100361310ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class FloatTest { @AuxCounters @State(Scope.Thread) public static class S { float cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IntTest.java000066400000000000000000000034241446271450100356210ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class IntTest { @AuxCounters @State(Scope.Thread) public static class S { int cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } LongTest.java000066400000000000000000000034261446271450100357700ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class LongTest { @AuxCounters @State(Scope.Thread) public static class S { long cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } ShortTest.java000066400000000000000000000034301446271450100361630ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ShortTest { @AuxCounters @State(Scope.Thread) public static class S { short cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } StringTest.java000066400000000000000000000034321446271450100363340ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class StringTest { @AuxCounters @State(Scope.Thread) public static class S { String cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/000077500000000000000000000000001446271450100336355ustar00rootroot00000000000000BooleanTest.java000066400000000000000000000034601446271450100366430ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class BooleanTest { @AuxCounters @State(Scope.Thread) public static class S { boolean cnt() { return false; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } ByteTest.java000066400000000000000000000034461446271450100361730ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ByteTest { @AuxCounters @State(Scope.Thread) public static class S { byte cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } CharTest.java000066400000000000000000000034461446271450100361450ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class CharTest { @AuxCounters @State(Scope.Thread) public static class S { char cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } DoubleTest.java000066400000000000000000000034521446271450100364770ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class DoubleTest { @AuxCounters @State(Scope.Thread) public static class S { double cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } FloatTest.java000066400000000000000000000034501446271450100363300ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class FloatTest { @AuxCounters @State(Scope.Thread) public static class S { float cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IntTest.java000066400000000000000000000034441446271450100360200ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class IntTest { @AuxCounters @State(Scope.Thread) public static class S { int cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } LongTest.java000066400000000000000000000034461446271450100361670ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class LongTest { @AuxCounters @State(Scope.Thread) public static class S { long cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } ShortTest.java000066400000000000000000000034501446271450100363620ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ShortTest { @AuxCounters @State(Scope.Thread) public static class S { short cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } StringTest.java000066400000000000000000000034531446271450100365340ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class StringTest { @AuxCounters @State(Scope.Thread) public static class S { String cnt() { return ""; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } VoidTest.java000066400000000000000000000034341446271450100361660ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class VoidTest { @AuxCounters @State(Scope.Thread) public static class S { void cnt() { } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/000077500000000000000000000000001446271450100332445ustar00rootroot00000000000000BooleanTest.java000066400000000000000000000035111446271450100362470ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class BooleanTest { @AuxCounters @State(Scope.Thread) public static class S { public boolean cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Illegal type for the public field"); } } ByteTest.java000066400000000000000000000034341446271450100355770ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ByteTest { @AuxCounters @State(Scope.Thread) public static class S { public byte cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } CharTest.java000066400000000000000000000035031446271450100355460ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class CharTest { @AuxCounters @State(Scope.Thread) public static class S { public char cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Illegal type for the public field"); } } DoubleTest.java000066400000000000000000000034401446271450100361030ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class DoubleTest { @AuxCounters @State(Scope.Thread) public static class S { public double cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } FloatTest.java000066400000000000000000000034361446271450100357430ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class FloatTest { @AuxCounters @State(Scope.Thread) public static class S { public float cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IntTest.java000066400000000000000000000034321446271450100354240ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class IntTest { @AuxCounters @State(Scope.Thread) public static class S { public int cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } LongTest.java000066400000000000000000000034341446271450100355730ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class LongTest { @AuxCounters @State(Scope.Thread) public static class S { public long cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } ShortTest.java000066400000000000000000000034361446271450100357750ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ShortTest { @AuxCounters @State(Scope.Thread) public static class S { public short cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } StringTest.java000066400000000000000000000035071446271450100361430ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class StringTest { @AuxCounters @State(Scope.Thread) public static class S { public String cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Illegal type for the public field"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/000077500000000000000000000000001446271450100334415ustar00rootroot00000000000000BooleanTest.java000066400000000000000000000035551446271450100364540ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class BooleanTest { @AuxCounters @State(Scope.Thread) public static class S { public boolean cnt() { return false; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Illegal type for the return type of public method"); } } ByteTest.java000066400000000000000000000034541446271450100357760ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ByteTest { @AuxCounters @State(Scope.Thread) public static class S { public byte cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } CharTest.java000066400000000000000000000035431446271450100357470ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class CharTest { @AuxCounters @State(Scope.Thread) public static class S { public char cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Illegal type for the return type of public method"); } } DoubleTest.java000066400000000000000000000034601446271450100363020ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class DoubleTest { @AuxCounters @State(Scope.Thread) public static class S { public double cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } FloatTest.java000066400000000000000000000034561446271450100361420ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class FloatTest { @AuxCounters @State(Scope.Thread) public static class S { public float cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IntTest.java000066400000000000000000000034521446271450100356230ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class IntTest { @AuxCounters @State(Scope.Thread) public static class S { public int cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } LongTest.java000066400000000000000000000034541446271450100357720ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class LongTest { @AuxCounters @State(Scope.Thread) public static class S { public long cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } ShortTest.java000066400000000000000000000034561446271450100361740ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ShortTest { @AuxCounters @State(Scope.Thread) public static class S { public short cnt() { return 0; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } StringTest.java000066400000000000000000000035501446271450100363360ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class StringTest { @AuxCounters @State(Scope.Thread) public static class S { public String cnt() { return ""; } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "Illegal type for the return type of public method"); } } VoidTest.java000066400000000000000000000034711446271450100357730ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class VoidTest { @AuxCounters @State(Scope.Thread) public static class S { public void cnt() { } } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/000077500000000000000000000000001446271450100272445ustar00rootroot00000000000000BenchmarkStateTest.java000066400000000000000000000032401446271450100335620ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.scope; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class BenchmarkStateTest { @AuxCounters @State(Scope.Benchmark) public static class S { } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "can only be used with Scope.Thread states"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/GroupStateTest.java000066400000000000000000000032501446271450100330440ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.scope; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class GroupStateTest { @AuxCounters @State(Scope.Group) public static class S { } @Benchmark @Group("T") public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "can only be used with Scope.Thread states"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/ThreadStateTest.java000066400000000000000000000033671446271450100331700ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.scope; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ThreadStateTest { @AuxCounters @State(Scope.Thread) public static class S { } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/000077500000000000000000000000001446271450100272775ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/000077500000000000000000000000001446271450100306035ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/ByteTest.java000066400000000000000000000034501446271450100332130ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.events; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ByteTest { @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class S { public byte cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/DoubleTest.java000066400000000000000000000034541446271450100335260ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.events; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class DoubleTest { @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class S { public double cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/FloatTest.java000066400000000000000000000034521446271450100333570ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.events; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class FloatTest { @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class S { public float cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/IntTest.java000066400000000000000000000034461446271450100330470ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.events; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class IntTest { @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class S { public int cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/LongTest.java000066400000000000000000000034501446271450100332070ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.events; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class LongTest { @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class S { public long cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/ShortTest.java000066400000000000000000000034521446271450100334110ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.events; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ShortTest { @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class S { public short cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/000077500000000000000000000000001446271450100314625ustar00rootroot00000000000000ByteTest.java000066400000000000000000000034601446271450100340140ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.operations; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ByteTest { @AuxCounters(AuxCounters.Type.OPERATIONS) @State(Scope.Thread) public static class S { public byte cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } DoubleTest.java000066400000000000000000000034641446271450100343270ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.operations; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class DoubleTest { @AuxCounters(AuxCounters.Type.OPERATIONS) @State(Scope.Thread) public static class S { public double cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } FloatTest.java000066400000000000000000000034621446271450100341600ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.operations; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class FloatTest { @AuxCounters(AuxCounters.Type.OPERATIONS) @State(Scope.Thread) public static class S { public float cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IntTest.java000066400000000000000000000034561446271450100336500ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.operations; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class IntTest { @AuxCounters(AuxCounters.Type.OPERATIONS) @State(Scope.Thread) public static class S { public int cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } LongTest.java000066400000000000000000000034601446271450100340100ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.operations; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class LongTest { @AuxCounters(AuxCounters.Type.OPERATIONS) @State(Scope.Thread) public static class S { public long cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } ShortTest.java000066400000000000000000000034621446271450100342120ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.other.auxcounters.types.operations; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ShortTest { @AuxCounters(AuxCounters.Type.OPERATIONS) @State(Scope.Thread) public static class S { public short cnt; } @Benchmark public void benchmark(S s) { // intentionally left blank } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/package-info.java000066400000000000000000000024531446271450100267460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * This is a sample package-info to test JMH treats these properly. */ package org.openjdk.jmh.ct.other; jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/000077500000000000000000000000001446271450100237155ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamAccessDefaultTest.java000066400000000000000000000045211446271450100311110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ParamAccessDefaultTest { @Param("true") boolean param_boolean; @Param("0") byte param_byte; @Param("0") short param_short; @Param("0") char param_char; @Param("0") int param_int; @Param("0") float param_float; @Param("0") long param_long; @Param("0") double param_double; @Param("true") Boolean param_Boolean; @Param("0") Byte param_Byte; @Param("0") Short param_Short; @Param("0") Character param_Char; @Param("0") Integer param_Int; @Param("0") Float param_Float; @Param("0") Long param_Long; @Param("0") Double param_Double; @Param("null") String param_String; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamAccessPrivateTest.java000066400000000000000000000047311446271450100311420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ParamAccessPrivateTest { @Param("true") private boolean param_boolean; @Param("0") private byte param_byte; @Param("0") private short param_short; @Param("0") private char param_char; @Param("0") private int param_int; @Param("0") private float param_float; @Param("0") private long param_long; @Param("0") private double param_double; @Param("true") private Boolean param_Boolean; @Param("0") private Byte param_Byte; @Param("0") private Short param_Short; @Param("0") private Character param_Char; @Param("0") private Integer param_Int; @Param("0") private Float param_Float; @Param("0") private Long param_Long; @Param("0") private Double param_Double; @Param("null") private String param_String; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamAccessProtectedTest.java000066400000000000000000000047751446271450100314710ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ParamAccessProtectedTest { @Param("true") protected boolean param_boolean; @Param("0") protected byte param_byte; @Param("0") protected short param_short; @Param("0") protected char param_char; @Param("0") protected int param_int; @Param("0") protected float param_float; @Param("0") protected long param_long; @Param("0") protected double param_double; @Param("true") protected Boolean param_Boolean; @Param("0") protected Byte param_Byte; @Param("0") protected Short param_Short; @Param("0") protected Character param_Char; @Param("0") protected Integer param_Int; @Param("0") protected Float param_Float; @Param("0") protected Long param_Long; @Param("0") protected Double param_Double; @Param("null") protected String param_String; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamAccessPublicTest.java000066400000000000000000000047071446271450100307510ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ParamAccessPublicTest { @Param("true") public boolean param_boolean; @Param("0") public byte param_byte; @Param("0") public short param_short; @Param("0") public char param_char; @Param("0") public int param_int; @Param("0") public float param_float; @Param("0") public long param_long; @Param("0") public double param_double; @Param("true") public Boolean param_Boolean; @Param("0") public Byte param_Byte; @Param("0") public Short param_Short; @Param("0") public Character param_Char; @Param("0") public Integer param_Int; @Param("0") public Float param_Float; @Param("0") public Long param_Long; @Param("0") public Double param_Double; @Param("null") public String param_String; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamBlankTest.java000066400000000000000000000045721446271450100274400ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ParamBlankTest { @Param public boolean param_boolean; @Param public byte param_byte; @Param public short param_short; @Param public char param_char; @Param public int param_int; @Param public float param_float; @Param public long param_long; @Param public double param_double; @Param public Boolean param_Boolean; @Param public Byte param_Byte; @Param public Short param_Short; @Param public Character param_Char; @Param public Integer param_Int; @Param public Float param_Float; @Param public Long param_Long; @Param public Double param_Double; @Param public String param_String; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "default parameters"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamEscapesTest.java000066400000000000000000000036031446271450100277660ustar00rootroot00000000000000/* * Copyright (c) 2019, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ParamEscapesTest { @Param("value") public String param_plain; @Param("value\n") public String param_n; @Param("value\r") public String param_r; @Param("value\r\n") public String param_rn; @Param("value\n\r") public String param_nr; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamOverridingTest.java000066400000000000000000000035741446271450100305220ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ParamOverridingTest { @Param("value") private String param; @Benchmark public void test1() {} public static class OverridingTest extends ParamOverridingTest { @Param("newvalue") private String param; @Benchmark public void test2() {} } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamQuotesTest.java000066400000000000000000000036211446271450100276630ustar00rootroot00000000000000/* * Copyright (c) 2019, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ParamQuotesTest { @Param("value") public String param_plain; @Param("[value]") public String param_square; @Param("{value}") public String param_curly; @Param("'value'") public String param_squote; @Param("\"value\"") public String param_dquote; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamValuedTest.java000066400000000000000000000047011446271450100276230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ParamValuedTest { @Param("true") public boolean param_boolean; @Param("0") public byte param_byte; @Param("0") public short param_short; @Param("0") public char param_char; @Param("0") public int param_int; @Param("0") public float param_float; @Param("0") public long param_long; @Param("0") public double param_double; @Param("true") public Boolean param_Boolean; @Param("0") public Byte param_Byte; @Param("0") public Short param_Short; @Param("0") public Character param_Char; @Param("0") public Integer param_Int; @Param("0") public Float param_Float; @Param("0") public Long param_Long; @Param("0") public Double param_Double; @Param("null") public String param_String; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/SampleEnum.java000066400000000000000000000024421446271450100266300ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params; public enum SampleEnum { VALUE_EXIST_1, VALUE_EXIST_2, } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/000077500000000000000000000000001446271450100253435ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/BooleanArrayTest.java000066400000000000000000000033551446271450100314320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class BooleanArrayTest { @Param("0") public boolean[] param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/BooleanTest.java000066400000000000000000000033111446271450100304230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class BooleanTest { @Param("foo") public boolean param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/Byte1Test.java000066400000000000000000000033041446271450100300320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class Byte1Test { @Param("foo") public byte param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/Byte2Test.java000066400000000000000000000033041446271450100300330ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class Byte2Test { @Param("0.0") public byte param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/Byte3Test.java000066400000000000000000000033051446271450100300350ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class Byte3Test { @Param("4242") public byte param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/ByteArrayTest.java000066400000000000000000000033471446271450100307570ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ByteArrayTest { @Param("0") public byte[] param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/CharArrayTest.java000066400000000000000000000033471446271450100307310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class CharArrayTest { @Param("0") public char[] param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/CharTest.java000066400000000000000000000033031446271450100277220ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class CharTest { @Param("foo") public char param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/DoubleArrayTest.java000066400000000000000000000033531446271450100312630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class DoubleArrayTest { @Param("0") public double[] param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/DoubleTest.java000066400000000000000000000033071446271450100302630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class DoubleTest { @Param("foo") public double param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/EnumTest.java000066400000000000000000000034601446271450100277550ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.ct.params.SampleEnum; @State(Scope.Benchmark) public class EnumTest { @Param("VALUE_NOT_EXIST") public SampleEnum param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "values can not be converted to target type"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/FloatArrayTest.java000066400000000000000000000033511446271450100311140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class FloatArrayTest { @Param("0") public float[] param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/FloatTest.java000066400000000000000000000033051446271450100301140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class FloatTest { @Param("foo") public float param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/Int1Test.java000066400000000000000000000033021446271450100276570ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class Int1Test { @Param("foo") public int param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/Int2Test.java000066400000000000000000000033021446271450100276600ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class Int2Test { @Param("0.0") public int param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/Int3Test.java000066400000000000000000000033121446271450100276620ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class Int3Test { @Param("10000000000") public int param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/IntArrayTest.java000066400000000000000000000033451446271450100306040ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class IntArrayTest { @Param("0") public int[] param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/LongArrayTest.java000066400000000000000000000033471446271450100307530ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class LongArrayTest { @Param("0") public long[] param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/LongTest.java000066400000000000000000000033031446271450100277440ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class LongTest { @Param("foo") public long param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/ObjectArrayTest.java000066400000000000000000000033531446271450100312570ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ObjectArrayTest { @Param("0") public Object[] param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/ObjectTest.java000066400000000000000000000033441446271450100302600ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ObjectTest { @Param("0") public Object param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/Short1Test.java000066400000000000000000000033061446271450100302300ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class Short1Test { @Param("foo") public short param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/Short2Test.java000066400000000000000000000033061446271450100302310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class Short2Test { @Param("0.0") public short param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/Short3Test.java000066400000000000000000000033111446271450100302260ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class Short3Test { @Param("100000") public short param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/ShortArrayTest.java000066400000000000000000000033511446271450100311460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ShortArrayTest { @Param("0") public short[] param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/StringArrayTest.java000066400000000000000000000033531446271450100313170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class StringArrayTest { @Param("0") public String[] param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "annotation-compatible types"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/finals/000077500000000000000000000000001446271450100266175ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/finals/BooleanTest.java000066400000000000000000000033601446271450100317030ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid.finals; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class BooleanTest { @Param("false") public final boolean param = false; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "final fields"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/finals/ByteTest.java000066400000000000000000000033421446271450100312270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid.finals; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ByteTest { @Param("0") public final byte param = 0; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "final fields"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/finals/CharTest.java000066400000000000000000000033441446271450100312030ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid.finals; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class CharTest { @Param("a") public final char param = 'a'; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "final fields"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/finals/DoubleTest.java000066400000000000000000000033521446271450100315370ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid.finals; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class DoubleTest { @Param("0.0") public final double param = 0.1; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "final fields"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/finals/EnumTest.java000066400000000000000000000034701446271450100312320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid.finals; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.ct.params.SampleEnum; @State(Scope.Benchmark) public class EnumTest { @Param("VALUE_EXIST_1") public final SampleEnum param = SampleEnum.VALUE_EXIST_1; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "final fields"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/finals/FloatTest.java000066400000000000000000000033511446271450100313710ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid.finals; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class FloatTest { @Param("0.0") public final float param = 0.1f; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "final fields"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/finals/LongTest.java000066400000000000000000000033421446271450100312230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid.finals; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class LongTest { @Param("0") public final long param = 0; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "final fields"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/invalid/finals/Short1Test.java000066400000000000000000000033451446271450100315070ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.invalid.finals; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class Short1Test { @Param("0") public final short param = 0; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "final fields"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/000077500000000000000000000000001446271450100250145ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/BooleanTest.java000066400000000000000000000033061446271450100301000ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class BooleanTest { @Param("true") public boolean param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/ByteTest.java000066400000000000000000000032751446271450100274310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ByteTest { @Param("0") public byte param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/CharTest.java000066400000000000000000000032751446271450100274030ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class CharTest { @Param("0") public char param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/DoubleTest.java000066400000000000000000000033011446271450100277260ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class DoubleTest { @Param("0") public double param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/EmptyStringTest.java000066400000000000000000000033051446271450100310050ustar00rootroot00000000000000/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class EmptyStringTest { @Param("") public String param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/EnumTest.java000066400000000000000000000034651446271450100274330ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.ct.params.SampleEnum; @State(Scope.Benchmark) public class EnumTest { @Param("VALUE_EXIST_1") public SampleEnum paramExplicit; @Param public SampleEnum paramImplicit; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/FloatTest.java000066400000000000000000000032771446271450100275750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class FloatTest { @Param("0") public float param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/IntTest.java000066400000000000000000000032731446271450100272560ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class IntTest { @Param("0") public int param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/LongTest.java000066400000000000000000000032751446271450100274250ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class LongTest { @Param("0") public long param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/ShortTest.java000066400000000000000000000032771446271450100276270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ShortTest { @Param("0") public short param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/StringTest.java000066400000000000000000000033011446271450100277620ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class StringTest { @Param("0") public String param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/000077500000000000000000000000001446271450100264665ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/BooleanTest.java000066400000000000000000000033251446271450100315530ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid.statics; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class BooleanTest { @Param("true") public static boolean param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/ByteTest.java000066400000000000000000000033141446271450100310750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid.statics; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ByteTest { @Param("0") public static byte param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/CharTest.java000066400000000000000000000033141446271450100310470ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid.statics; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class CharTest { @Param("0") public static char param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/DoubleTest.java000066400000000000000000000033201446271450100314010ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid.statics; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class DoubleTest { @Param("0") public static double param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/EnumTest.java000066400000000000000000000035131446271450100310770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid.statics; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.ct.params.SampleEnum; @State(Scope.Benchmark) public class EnumTest { @Param("VALUE_EXIST_1") public static SampleEnum paramExplicit; @Param public static SampleEnum paramImplicit; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/FloatTest.java000066400000000000000000000033161446271450100312410ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid.statics; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class FloatTest { @Param("0") public static float param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/IntTest.java000066400000000000000000000033121446271450100307220ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid.statics; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class IntTest { @Param("0") public static int param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/LongTest.java000066400000000000000000000033141446271450100310710ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid.statics; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class LongTest { @Param("0") public static long param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/ShortTest.java000066400000000000000000000033161446271450100312730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid.statics; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ShortTest { @Param("0") public static short param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/valid/statics/StringTest.java000066400000000000000000000033201446271450100314350ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.params.valid.statics; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class StringTest { @Param("0") public static String param; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/000077500000000000000000000000001446271450100237355ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/InnerTest.java000066400000000000000000000032051446271450100265130ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class InnerTest { @State(Scope.Benchmark) class S { } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/NestedTest.java000066400000000000000000000032151446271450100266630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class NestedTest { @State(Scope.Benchmark) static class S { } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/PublicAbstractNestedTest.java000066400000000000000000000032531446271450100315100ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PublicAbstractNestedTest { @State(Scope.Benchmark) public abstract static class S { } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/PublicInnerTest.java000066400000000000000000000032221446271450100276510ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PublicInnerTest { @State(Scope.Benchmark) public class S { } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/PublicNestedFinalTest.java000066400000000000000000000032451446271450100307770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PublicNestedFinalTest { @State(Scope.Benchmark) public static final class S { } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/PublicNestedNoConstrTest.java000066400000000000000000000033351446271450100315130ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PublicNestedNoConstrTest { @State(Scope.Benchmark) public static class S { public S(int value) { // d'uh } } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/PublicNestedPrivConstrTest.java000066400000000000000000000033171446271450100320570ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PublicNestedPrivConstrTest { @State(Scope.Benchmark) public static class S { S() { // d'uh } } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/PublicNestedTest.java000066400000000000000000000032301446271450100300170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PublicNestedTest { @State(Scope.Benchmark) public static class S { } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/000077500000000000000000000000001446271450100244705ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/AbstractDependencyTest.java000066400000000000000000000037131446271450100317410ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class AbstractDependencyTest { @State(Scope.Benchmark) public abstract static class A { @Setup(Level.Trial) public void setup() {} protected abstract void helper(); } public static class CA extends A { @Override protected void helper() { // do nothing } } @State(Scope.Thread) public static class B { @Setup(Level.Trial) public void setup(A b2) {} } @Benchmark public void test(CA ca, B b) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "abstract"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/BasicTest.java000066400000000000000000000036021446271450100272150ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class BasicTest { @State(Scope.Benchmark) public static class B1 { } @State(Scope.Benchmark) public static class B2 { } @State(Scope.Thread) public static class L { @Setup public void setup(B1 b1, B2 b2) { } } @Benchmark public void test(L l) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/Chain1Test.java000066400000000000000000000032301446271450100272740ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class Chain1Test { @State(Scope.Benchmark) public static class B1 { } @Benchmark public void test(B1 b) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/Chain2Test.java000066400000000000000000000035541446271450100273060ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class Chain2Test { @State(Scope.Benchmark) public static class B2 { } @State(Scope.Benchmark) public static class B1 { @Setup(Level.Trial) public void setup(B2 b2) {} } @Benchmark public void test(B1 b) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/Chain3Test.java000066400000000000000000000037541446271450100273110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class Chain3Test { @State(Scope.Benchmark) public static class B3 { } @State(Scope.Benchmark) public static class B2 { @Setup(Level.Trial) public void setup(B3 b2) {} } @State(Scope.Benchmark) public static class B1 { @Setup(Level.Trial) public void setup(B2 b2) {} } @Benchmark public void test(B1 b) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/Chain4Test.java000066400000000000000000000041541446271450100273050ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class Chain4Test { @State(Scope.Benchmark) public static class B4 { } @State(Scope.Benchmark) public static class B3 { @Setup(Level.Trial) public void setup(B4 b2) {} } @State(Scope.Benchmark) public static class B2 { @Setup(Level.Trial) public void setup(B3 b2) {} } @State(Scope.Benchmark) public static class B1 { @Setup(Level.Trial) public void setup(B2 b2) {} } @Benchmark public void test(B1 b) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CutThroughTest.java000066400000000000000000000036151446271450100302740ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class CutThroughTest { @State(Scope.Benchmark) public static class B1 { } @State(Scope.Benchmark) public static class B2 { } @State(Scope.Thread) public static class L { @Setup public void setup(B1 b1, B2 b2) { } } @Benchmark public void test(L l, B1 b1) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/GroupTest.java000066400000000000000000000040051446271450100272660ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class GroupTest { @State(Scope.Benchmark) public static class B1 { } @State(Scope.Benchmark) public static class B2 { } @State(Scope.Group) public static class L { @Setup public void setup(B1 b1, B2 b2) { } } @Benchmark @Group("test") public void test1(L l) { } @Benchmark @Group("test") public void test2(L l) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/SelfBenchmarkTest.java000066400000000000000000000034101446271450100306750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class SelfBenchmarkTest { @State(Scope.Benchmark) public static class B1 { @Setup public void setup(B1 b1) { } } @Benchmark public void test(B1 b1) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/SelfThreadTest.java000066400000000000000000000035231446271450100302170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class SelfThreadTest { @State(Scope.Thread) public static class B1 { @Param private int x; @Setup public void setup(B1 b1) { } } @Benchmark public void test(B1 b1) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/000077500000000000000000000000001446271450100257525ustar00rootroot00000000000000ExplicitCycleBenchmarkTest.java000066400000000000000000000036741446271450100337640ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.cycles; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ExplicitCycleBenchmarkTest { @State(Scope.Benchmark) public static class B1 { @Setup public void setup(B2 b1) { } } @State(Scope.Benchmark) public static class B2 { @Setup public void setup(B1 b1) { } } @Benchmark public void test(B1 b1) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleThreadTest.java000066400000000000000000000036631446271450100333560ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.cycles; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ExplicitCycleThreadTest { @State(Scope.Thread) public static class B1 { @Setup public void setup(B2 b1) { } } @State(Scope.Thread) public static class B2 { @Setup public void setup(B1 b1) { } } @Benchmark public void test(B1 b1) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected"); } } ImplicitCycleBenchmarkTest.java000066400000000000000000000036341446271450100337510ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.cycles; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ImplicitCycleBenchmarkTest { @State(Scope.Benchmark) public static class B1 { @Setup public void setup(ImplicitCycleBenchmarkTest b1) { } } @Setup public void setup(B1 b1) { } @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected"); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleThreadTest.java000066400000000000000000000036201446271450100333400ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.cycles; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Thread) public class ImplicitCycleThreadTest { @State(Scope.Thread) public static class B1 { @Setup public void setup(ImplicitCycleThreadTest b1) { } } @Setup public void setup(B1 b1) { } @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected"); } } NoDoubleUseCycleBenchmarkTest.java000066400000000000000000000034151446271450100343600ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/* * Copyright (c) 2020, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.cycles; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class NoDoubleUseCycleBenchmarkTest { @State(Scope.Benchmark) public static class B { } @State(Scope.Benchmark) public static class A { @Setup public void setup(B b1, B b2) { } @TearDown public void teardown(B b1, B b2) { } } @Benchmark public void test(A a1, A a2) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } NoDoubleUseCycleThreadTest.java000066400000000000000000000034041446271450100336730ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/* * Copyright (c) 2020, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.cycles; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class NoDoubleUseCycleThreadTest { @State(Scope.Thread) public static class B { } @State(Scope.Thread) public static class A { @Setup public void setup(B b1, B b2) { } @TearDown public void teardown(B b1, B b2) { } } @Benchmark public void test(A a1, A a2) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/000077500000000000000000000000001446271450100263115ustar00rootroot00000000000000BenchmarkBenchmarkTest.java000066400000000000000000000034401446271450100334430ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.doublets; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class BenchmarkBenchmarkTest { @State(Scope.Benchmark) public static class L { } @State(Scope.Benchmark) public static class G { @Setup public void setup(L l1, L l2) { } @TearDown public void teardown(L l1, L l2) { } } @Benchmark public void test(G g1, G g2) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java000066400000000000000000000034321446271450100330400ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.doublets; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class BenchmarkThreadTest { @State(Scope.Benchmark) public static class L { } @State(Scope.Thread) public static class G { @Setup public void setup(L l1, L l2) { } @TearDown public void teardown(L l1, L l2) { } } @Benchmark public void test(G g1, G g2) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java000066400000000000000000000034321446271450100330400ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.doublets; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class ThreadBenchmarkTest { @State(Scope.Thread) public static class L { } @State(Scope.Benchmark) public static class G { @Setup public void setup(L l1, L l2) { } @TearDown public void teardown(L l1, L l2) { } } @Benchmark public void test(G g1, G g2) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java000066400000000000000000000034241446271450100323560ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.doublets; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class ThreadThreadTest { @State(Scope.Thread) public static class L { } @State(Scope.Thread) public static class G { @Setup public void setup(L l1, L l2) { } @TearDown public void teardown(L l1, L l2) { } } @Benchmark public void test(G g1, G g2) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/000077500000000000000000000000001446271450100263025ustar00rootroot00000000000000BenchmarkBenchmarkTest.java000066400000000000000000000034621446271450100334400ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class BenchmarkBenchmarkTest { @State(Scope.Benchmark) public static class L { } @Setup public void setup(L l1) { } @Benchmark public void test(BenchmarkBenchmarkTest state) {} @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkThreadTest.java000066400000000000000000000034511446271450100330320ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class BenchmarkThreadTest { @State(Scope.Thread) public static class L { } @Setup public void setup(L l1) { } @Benchmark public void test(BenchmarkThreadTest state) {} @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadBenchmarkTest.java000066400000000000000000000034511446271450100330320ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Thread) public class ThreadBenchmarkTest { @State(Scope.Benchmark) public static class L { } @Setup public void setup(L l1) { } @Benchmark public void test(ThreadBenchmarkTest state) {} @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadThreadTest.java000066400000000000000000000034401446271450100323450ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.dag.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Thread) public class ThreadThreadTest { @State(Scope.Thread) public static class L { } @Setup public void setup(L l1) { } @Benchmark public void test(ThreadThreadTest state) {} @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/fields/000077500000000000000000000000001446271450100252035ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/fields/NoStateInstanceTest.java000066400000000000000000000030411446271450100317460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.fields; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class NoStateInstanceTest { private int x; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/fields/NoStateStaticTest.java000066400000000000000000000030441446271450100314340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.fields; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.ct.CompileTest; public class NoStateStaticTest { private static int x; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/fields/StateInstanceTest.java000066400000000000000000000032111446271450100314500ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.fields; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class StateInstanceTest { private int x; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/fields/StateStaticTest.java000066400000000000000000000032161446271450100311400ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.fields; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class StateStaticTest { private static int x; @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/000077500000000000000000000000001446271450100253775ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/000077500000000000000000000000001446271450100272205ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/PackageTest.java000066400000000000000000000034551446271450100322650ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PackageTest { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) void setup() {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/PrivateTest.java000066400000000000000000000034651446271450100323450ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PrivateTest { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) private void setup() {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/ProtectedTest.java000066400000000000000000000034711446271450100326610ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class ProtectedTest { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) protected void setup() {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } PublicArgsControlTest.java000066400000000000000000000035551446271450100342500ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Control; public class PublicArgsControlTest { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(Control cnt) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/PublicArgsTest.java000066400000000000000000000035711446271450100327640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import java.util.concurrent.atomic.AtomicInteger; public class PublicArgsTest { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(AtomicInteger v) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/PublicFinalTest.java000066400000000000000000000034741446271450100331230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PublicFinalTest { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public final void setup() {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/PublicReturnTest.java000066400000000000000000000035301446271450100333420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PublicReturnTest { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public int setup() { return 42; } } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/PublicTest.java000066400000000000000000000034611446271450100321450ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; public class PublicTest { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup() {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/benchparams/000077500000000000000000000000001446271450100315035ustar00rootroot00000000000000InvocationBenchParams1Test.java000066400000000000000000000036221446271450100374300ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/benchparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.benchparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.BenchmarkParams; public class InvocationBenchParams1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(BenchmarkParams bp) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } InvocationBenchParams2Test.java000066400000000000000000000036461446271450100374370ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/benchparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.benchparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.BenchmarkParams; public class InvocationBenchParams2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(BenchmarkParams bh) {} } @Benchmark public void test(S s, BenchmarkParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } InvocationBenchParams3Test.java000066400000000000000000000040511446271450100374270ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/benchparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.benchparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.BenchmarkParams; public class InvocationBenchParams3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(BenchmarkParams bh) {} @TearDown(Level.Invocation) public void trial(BenchmarkParams bh) {} } @Benchmark public void test(S s, BenchmarkParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationBenchParams1Test.java000066400000000000000000000036201446271450100372530ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/benchparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.benchparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.BenchmarkParams; public class IterationBenchParams1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(BenchmarkParams bh) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationBenchParams2Test.java000066400000000000000000000036441446271450100372620ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/benchparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.benchparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.BenchmarkParams; public class IterationBenchParams2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(BenchmarkParams bh) {} } @Benchmark public void test(S s, BenchmarkParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationBenchParams3Test.java000066400000000000000000000040461446271450100372600ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/benchparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.benchparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.BenchmarkParams; public class IterationBenchParams3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(BenchmarkParams bh) {} @TearDown(Level.Iteration) public void trial(BenchmarkParams bh) {} } @Benchmark public void test(S s, BenchmarkParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialBenchParams1Test.java000066400000000000000000000036101446271450100363670ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/benchparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.benchparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.BenchmarkParams; public class TrialBenchParams1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(BenchmarkParams bh) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialBenchParams2Test.java000066400000000000000000000036341446271450100363760ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/benchparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.benchparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.BenchmarkParams; public class TrialBenchParams2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(BenchmarkParams bh) {} } @Benchmark public void test(S s, BenchmarkParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialBenchParams3Test.java000066400000000000000000000040321446271450100363700ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/benchparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.benchparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.BenchmarkParams; public class TrialBenchParams3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(BenchmarkParams bh) {} @TearDown(Level.Trial) public void trial(BenchmarkParams bh) {} } @Benchmark public void test(S s, BenchmarkParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/blackholes/000077500000000000000000000000001446271450100313275ustar00rootroot00000000000000InvocationBlackhole1Test.java000066400000000000000000000036031446271450100367540ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class InvocationBlackhole1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(Blackhole bh) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } InvocationBlackhole2Test.java000066400000000000000000000036211446271450100367550ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class InvocationBlackhole2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(Blackhole bh) {} } @Benchmark public void test(S s, Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } InvocationBlackhole3Test.java000066400000000000000000000040161446271450100367550ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class InvocationBlackhole3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(Blackhole bh) {} @TearDown(Level.Invocation) public void trial(Blackhole bh) {} } @Benchmark public void test(S s, Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationBlackhole1Test.java000066400000000000000000000036011446271450100365770ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class IterationBlackhole1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(Blackhole bh) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationBlackhole2Test.java000066400000000000000000000036171446271450100366070ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class IterationBlackhole2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(Blackhole bh) {} } @Benchmark public void test(S s, Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationBlackhole3Test.java000066400000000000000000000040131446271450100365770ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class IterationBlackhole3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(Blackhole bh) {} @TearDown(Level.Iteration) public void trial(Blackhole bh) {} } @Benchmark public void test(S s, Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialBlackhole1Test.java000066400000000000000000000035711446271450100357220ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class TrialBlackhole1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(Blackhole bh) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialBlackhole2Test.java000066400000000000000000000036071446271450100357230ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class TrialBlackhole2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(Blackhole bh) {} } @Benchmark public void test(S s, Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialBlackhole3Test.java000066400000000000000000000037771446271450100357340ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; public class TrialBlackhole3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(Blackhole bh) {} @TearDown(Level.Trial) public void trial(Blackhole bh) {} } @Benchmark public void test(S s, Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/iterparams/000077500000000000000000000000001446271450100313675ustar00rootroot00000000000000InvocationIterParams1Test.java000066400000000000000000000036201446271450100371760ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/iterparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.iterparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.IterationParams; public class InvocationIterParams1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(IterationParams bp) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } InvocationIterParams2Test.java000066400000000000000000000036441446271450100372050ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/iterparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.iterparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.IterationParams; public class InvocationIterParams2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(IterationParams bh) {} } @Benchmark public void test(S s, IterationParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } InvocationIterParams3Test.java000066400000000000000000000040471446271450100372040ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/iterparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.iterparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.IterationParams; public class InvocationIterParams3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(IterationParams bh) {} @TearDown(Level.Invocation) public void trial(IterationParams bh) {} } @Benchmark public void test(S s, IterationParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationIterParams1Test.java000066400000000000000000000036161446271450100370300ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/iterparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.iterparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.IterationParams; public class IterationIterParams1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(IterationParams bh) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationIterParams2Test.java000066400000000000000000000036421446271450100370300ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/iterparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.iterparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.IterationParams; public class IterationIterParams2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(IterationParams bh) {} } @Benchmark public void test(S s, IterationParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationIterParams3Test.java000066400000000000000000000040441446271450100370260ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/iterparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.iterparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.IterationParams; public class IterationIterParams3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(IterationParams bh) {} @TearDown(Level.Iteration) public void trial(IterationParams bh) {} } @Benchmark public void test(S s, IterationParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialIterParams1Test.java000066400000000000000000000036061446271450100361440ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/iterparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.iterparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.IterationParams; public class TrialIterParams1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(IterationParams bh) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialIterParams2Test.java000066400000000000000000000036321446271450100361440ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/iterparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.iterparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.IterationParams; public class TrialIterParams2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(IterationParams bh) {} } @Benchmark public void test(S s, IterationParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialIterParams3Test.java000066400000000000000000000040301446271450100361360ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/iterparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.iterparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.IterationParams; public class TrialIterParams3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(IterationParams bh) {} @TearDown(Level.Trial) public void trial(IterationParams bh) {} } @Benchmark public void test(S s, IterationParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/threadparams/000077500000000000000000000000001446271450100316735ustar00rootroot00000000000000InvocationThreadParams1Test.java000066400000000000000000000036161446271450100400130ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/threadparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.threadparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.ThreadParams; public class InvocationThreadParams1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(ThreadParams bp) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } InvocationThreadParams2Test.java000066400000000000000000000036371446271450100400170ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/threadparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.threadparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.ThreadParams; public class InvocationThreadParams2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(ThreadParams bh) {} } @Benchmark public void test(S s, ThreadParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } InvocationThreadParams3Test.java000066400000000000000000000040371446271450100400130ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/threadparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.threadparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.ThreadParams; public class InvocationThreadParams3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Invocation) public void setup(ThreadParams bh) {} @TearDown(Level.Invocation) public void trial(ThreadParams bh) {} } @Benchmark public void test(S s, ThreadParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationThreadParams1Test.java000066400000000000000000000036141446271450100376360ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/threadparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.threadparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.ThreadParams; public class IterationThreadParams1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(ThreadParams bh) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationThreadParams2Test.java000066400000000000000000000036351446271450100376420ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/threadparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.threadparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.ThreadParams; public class IterationThreadParams2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(ThreadParams bh) {} } @Benchmark public void test(S s, ThreadParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationThreadParams3Test.java000066400000000000000000000040341446271450100376350ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/threadparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.threadparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.ThreadParams; public class IterationThreadParams3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Iteration) public void setup(ThreadParams bh) {} @TearDown(Level.Iteration) public void trial(ThreadParams bh) {} } @Benchmark public void test(S s, ThreadParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialThreadParams1Test.java000066400000000000000000000036041446271450100367520ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/threadparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.threadparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.ThreadParams; public class TrialThreadParams1Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(ThreadParams bh) {} } @Benchmark public void test(S s) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialThreadParams2Test.java000066400000000000000000000036251446271450100367560ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/threadparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.threadparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.ThreadParams; public class TrialThreadParams2Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(ThreadParams bh) {} } @Benchmark public void test(S s, ThreadParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialThreadParams3Test.java000066400000000000000000000040201446271450100367450ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/explicit/threadparams/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.explicit.threadparams; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.ThreadParams; public class TrialThreadParams3Test { @State(Scope.Benchmark) public static class S { @Setup(Level.Trial) public void setup(ThreadParams bh) {} @TearDown(Level.Trial) public void trial(ThreadParams bh) {} } @Benchmark public void test(S s, ThreadParams bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/000077500000000000000000000000001446271450100272115ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/PackageTest.java000066400000000000000000000033741446271450100322560ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class PackageTest { @Setup(Level.Trial) void setup() {} @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/PrivateTest.java000066400000000000000000000034041446271450100323270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class PrivateTest { @Setup(Level.Trial) private void setup() {} @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/ProtectedTest.java000066400000000000000000000034101446271450100326430ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class ProtectedTest { @Setup(Level.Trial) protected void setup() {} @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } PublicArgsControlTest.java000066400000000000000000000034741446271450100342410ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Control; @State(Scope.Benchmark) public class PublicArgsControlTest { @Setup(Level.Trial) public void setup(Control cnt) {} @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/PublicArgsTest.java000066400000000000000000000035101446271450100327460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Benchmark) public class PublicArgsTest { @Setup(Level.Trial) public void setup(AtomicInteger v) {} @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/PublicFinalTest.java000066400000000000000000000034131446271450100331050ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class PublicFinalTest { @Setup(Level.Trial) public final void setup() {} @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/PublicReturnTest.java000066400000000000000000000034371446271450100333410ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class PublicReturnTest { @Setup(Level.Trial) public int setup() { return 42; } @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertFail(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/PublicTest.java000066400000000000000000000034001446271450100321270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; @State(Scope.Benchmark) public class PublicTest { @Setup(Level.Trial) public void setup() {} @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/blackholes/000077500000000000000000000000001446271450100313205ustar00rootroot00000000000000InvocationBlackhole1Test.java000066400000000000000000000035221446271450100367450ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; @State(Scope.Benchmark) public class InvocationBlackhole1Test { @Setup(Level.Invocation) public void setup(Blackhole bh) {} @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } InvocationBlackhole2Test.java000066400000000000000000000035361446271450100367530ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; @State(Scope.Benchmark) public class InvocationBlackhole2Test { @Setup(Level.Invocation) public void setup(Blackhole bh) {} @Benchmark public void test(Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } InvocationBlackhole3Test.java000066400000000000000000000037261446271450100367550ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; @State(Scope.Benchmark) public class InvocationBlackhole3Test { @Setup(Level.Invocation) public void setup(Blackhole bh) {} @TearDown(Level.Invocation) public void tearDown(Blackhole bh) {} @Benchmark public void test(Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationBlackhole1Test.java000066400000000000000000000035201446271450100365700ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; @State(Scope.Benchmark) public class IterationBlackhole1Test { @Setup(Level.Iteration) public void setup(Blackhole bh) {} @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationBlackhole2Test.java000066400000000000000000000035341446271450100365760ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; @State(Scope.Benchmark) public class IterationBlackhole2Test { @Setup(Level.Iteration) public void setup(Blackhole bh) {} @Benchmark public void test(Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } IterationBlackhole3Test.java000066400000000000000000000037231446271450100365770ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; @State(Scope.Benchmark) public class IterationBlackhole3Test { @Setup(Level.Iteration) public void setup(Blackhole bh) {} @TearDown(Level.Iteration) public void tearDown(Blackhole bh) {} @Benchmark public void test(Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialBlackhole1Test.java000066400000000000000000000035101446271450100357040ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; @State(Scope.Benchmark) public class TrialBlackhole1Test { @Setup(Level.Trial) public void setup(Blackhole bh) {} @Benchmark public void test() { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialBlackhole2Test.java000066400000000000000000000035241446271450100357120ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; @State(Scope.Benchmark) public class TrialBlackhole2Test { @Setup(Level.Trial) public void setup(Blackhole bh) {} @Benchmark public void test(Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } TrialBlackhole3Test.java000066400000000000000000000037071446271450100357160ustar00rootroot00000000000000jmh-1.37/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/helpers/implicit/blackholes/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.ct.states.helpers.implicit.blackholes; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.ct.CompileTest; import org.openjdk.jmh.infra.Blackhole; @State(Scope.Benchmark) public class TrialBlackhole3Test { @Setup(Level.Trial) public void setup(Blackhole bh) {} @TearDown(Level.Trial) public void tearDown(Blackhole bh) {} @Benchmark public void test(Blackhole bh) { } @Test public void compileTest() { CompileTest.assertOK(this.getClass()); } } jmh-1.37/jmh-core-it/000077500000000000000000000000001446271450100143445ustar00rootroot00000000000000jmh-1.37/jmh-core-it/LICENSE000066400000000000000000000455121446271450100153600ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-core-it/pom.xml000066400000000000000000000406661446271450100156750ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent 1.37 JMH Core Integration Tests jmh-core-it jar Oracle http://openjdk.java.net/ 2012 org.openjdk.jmh jmh-core ${project.version} junit junit test UTF-8 -Djmh.ignoreLock=true -Xms256m -Xmx256m -Djmh.core.it.profile=${jmh.core.it.profile} org.apache.maven.plugins maven-surefire-plugin ${jmh.testjvmargs} 1C false true com.mycila.maven-license-plugin maven-license-plugin format process-sources
file:///${project.basedir}/../src/license/gpl_cpe/header.txt
true true PHP
default default org.openjdk.jmh jmh-generator-annprocess ${project.version} provided true org.apache.maven.plugins maven-compiler-plugin executor-virtual executor-virtual org.openjdk.jmh jmh-generator-annprocess ${project.version} provided org.apache.maven.plugins maven-compiler-plugin org.apache.maven.plugins maven-surefire-plugin ${jmh.testjvmargs} -Djmh.executor=VIRTUAL executor-fjp executor-fjp org.openjdk.jmh jmh-generator-annprocess ${project.version} provided org.apache.maven.plugins maven-compiler-plugin org.apache.maven.plugins maven-surefire-plugin ${jmh.testjvmargs} -Djmh.executor=FJP executor-custom executor-custom org.openjdk.jmh jmh-generator-annprocess ${project.version} provided org.apache.maven.plugins maven-compiler-plugin org.apache.maven.plugins maven-surefire-plugin ${jmh.testjvmargs} -Djmh.executor=CUSTOM -Djmh.executor.class=org.openjdk.jmh.it.CustomExecutorService asm asm org.openjdk.jmh jmh-generator-bytecode ${project.version} org.apache.maven.plugins maven-compiler-plugin -proc:none default-testCompile none compile-java process-test-sources testCompile compile-jmh process-test-classes testCompile org.codehaus.mojo build-helper-maven-plugin add-source process-test-sources add-test-source ${project.build.testOutputDirectory}/generated-jmh-sources/ org.codehaus.mojo exec-maven-plugin process-test-sources java org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator ${project.build.testOutputDirectory} ${project.build.testOutputDirectory}/generated-jmh-sources/ ${project.build.testOutputDirectory} asm reflection reflection org.openjdk.jmh jmh-generator-bytecode ${project.version} org.apache.maven.plugins maven-compiler-plugin -proc:none default-testCompile none compile-java process-test-sources testCompile compile-jmh process-test-classes testCompile org.codehaus.mojo build-helper-maven-plugin add-source process-test-sources add-test-source ${project.build.testOutputDirectory}/generated-jmh-sources/ org.codehaus.mojo exec-maven-plugin process-test-sources java org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator ${project.build.testOutputDirectory} ${project.build.testOutputDirectory}/generated-jmh-sources/ ${project.build.testOutputDirectory} reflection
jmh-1.37/jmh-core-it/src/000077500000000000000000000000001446271450100151335ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/main/000077500000000000000000000000001446271450100160575ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/main/java/000077500000000000000000000000001446271450100170005ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/main/java/org/000077500000000000000000000000001446271450100175675ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/main/java/org/openjdk/000077500000000000000000000000001446271450100212215ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/main/java/org/openjdk/jmh/000077500000000000000000000000001446271450100217775ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/main/java/org/openjdk/jmh/it/000077500000000000000000000000001446271450100224135ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/main/java/org/openjdk/jmh/it/CustomExecutorService.java000066400000000000000000000063171446271450100275770ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.*; /** * Synthetic executor service to test the corner case where executor always starts * the task in the separate thread. Tests JMH invariants to the limit. */ public class CustomExecutorService implements ExecutorService { public CustomExecutorService(int maxThreads, String prefix) { // Do nothing } @Override public void shutdown() { // Do nothing } @Override public List shutdownNow() { return new ArrayList<>(); } @Override public boolean isShutdown() { return false; } @Override public boolean isTerminated() { return false; } @Override public boolean awaitTermination(long timeout, TimeUnit unit) { return true; } @Override public Future submit(Callable task) { FutureTask ft = new FutureTask<>(task); new Thread(ft).start(); return ft; } @Override public void execute(Runnable command) { new Thread(command).start(); } @Override public Future submit(Runnable task, T result) { throw new UnsupportedOperationException(); } @Override public Future submit(Runnable task) { throw new UnsupportedOperationException(); } @Override public List> invokeAll(Collection> tasks) { throw new UnsupportedOperationException(); } @Override public List> invokeAll(Collection> tasks, long timeout, TimeUnit unit) { throw new UnsupportedOperationException(); } @Override public T invokeAny(Collection> tasks) { throw new UnsupportedOperationException(); } @Override public T invokeAny(Collection> tasks, long timeout, TimeUnit unit) { throw new UnsupportedOperationException(); } } jmh-1.37/jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/000077500000000000000000000000001446271450100242205ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/CustomAnnotation.java000066400000000000000000000027521446271450100303760ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.annsteal; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface CustomAnnotation { } jmh-1.37/jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/CustomBenchmarkProcessor.java000066400000000000000000000056171446271450100320610ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.annsteal; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.tools.FileObject; import javax.tools.StandardLocation; import java.io.IOException; import java.io.Writer; import java.util.Set; @SupportedAnnotationTypes("*") public class CustomBenchmarkProcessor extends AbstractProcessor { public static final String CBP_LIST = "tmp/CBP.list"; @Override public SourceVersion getSupportedSourceVersion() { // We may claim to support the latest version, since we are not using // any version-specific extensions. return SourceVersion.latest(); } @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { for (TypeElement te : annotations) { if (te.getQualifiedName().toString().equals(CustomAnnotation.class.getCanonicalName())) { try { FileObject file = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", CBP_LIST); Writer writer = file.openWriter(); Set els = roundEnv.getElementsAnnotatedWith(te); for (Element el : els) { writer.append(el.getSimpleName()); } writer.close(); } catch (IOException e) { throw new IllegalStateException(e); } } } return false; } } jmh-1.37/jmh-core-it/src/test/000077500000000000000000000000001446271450100161125ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/000077500000000000000000000000001446271450100170335ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/000077500000000000000000000000001446271450100176225ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/000077500000000000000000000000001446271450100212545ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/000077500000000000000000000000001446271450100220325ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/000077500000000000000000000000001446271450100224465ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/Fixtures.java000066400000000000000000000050551446271450100251270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.concurrent.TimeUnit; public class Fixtures { private static final int REPS; private static final String PROFILE; static { REPS = AccessController.doPrivileged(new PrivilegedAction() { public Integer run() { return Integer.getInteger("jmh.it.reps", 1); } }); PROFILE = AccessController.doPrivileged(new PrivilegedAction() { public String run() { return System.getProperty("jmh.core.it.profile"); } }); } public static int repetitionCount() { return REPS; } public static String getTestMask(Class klass) { return klass.getCanonicalName(); } public static void work() { // courtesy for parallel-running tests try { TimeUnit.MILLISECONDS.sleep(10); } catch (InterruptedException e) { throw new IllegalStateException(e); } } public static boolean expectStableThreads() { return isDefaultProfile(); } public static boolean isDefaultProfile() { return PROFILE.equals("default"); } public static boolean isVirtualExecutor() { return PROFILE.contains("executor-virtual"); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/IterationCountAnnTest.java000066400000000000000000000056111446271450100275600ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness favors the iteration count annotations. */ @State(Scope.Thread) public class IterationCountAnnTest { private final AtomicInteger count = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { count.incrementAndGet(); } @TearDown public void tearDown() { Assert.assertEquals("Single iteration expected", 1, count.get()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/IterationCountCmdTest.java000066400000000000000000000055421446271450100275520ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness favors the iteration count cmdline parameters. */ @State(Scope.Thread) public class IterationCountCmdTest { private final AtomicInteger count = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { count.incrementAndGet(); } @TearDown public void tearDown() { Assert.assertEquals("Single iteration expected", 1, count.get()); } @Benchmark @BenchmarkMode(Mode.All) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(100)) .warmupIterations(0) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/SingleShotTest.java000066400000000000000000000057171446271450100262420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness had indeed executed different tests in different JVMs. */ @BenchmarkMode(Mode.SingleShotTime) public class SingleShotTest { private static final AtomicInteger test1executed = new AtomicInteger(); private static final AtomicInteger test2executed = new AtomicInteger(); @Benchmark @Fork(1) public void test1() { Fixtures.work(); Assert.assertEquals(1, test1executed.incrementAndGet()); Assert.assertEquals(0, test2executed.get()); } @Benchmark @Fork(1) public void test2() { Fixtures.work(); Assert.assertEquals(1, test2executed.incrementAndGet()); Assert.assertEquals(0, test1executed.get()); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); } @Test public void invokeAPI_1() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(2) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/StackTraceInThrowableTest.java000066400000000000000000000046351446271450100303440ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Thread) public class StackTraceInThrowableTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .jvmArgs("-XX:-StackTraceInThrowable") .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/WarmupIterationCountAnnTest.java000066400000000000000000000056671446271450100307670ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness honors warmup annotation settings. */ @State(Scope.Thread) public class WarmupIterationCountAnnTest { private final AtomicInteger count = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { count.incrementAndGet(); } @TearDown public void tearDown() { Assert.assertEquals("Four iterations expected", 4, count.get()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 3, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/WarmupIterationCountCmdTest.java000066400000000000000000000056271446271450100307520ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness honors warmup command line settings. */ @State(Scope.Thread) public class WarmupIterationCountCmdTest { private final AtomicInteger count = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { count.incrementAndGet(); } @TearDown public void tearDown() { Assert.assertEquals("Four iterations expected", 4, count.get()); } @Benchmark @BenchmarkMode(Mode.All) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupTime(TimeValue.milliseconds(100)) .measurementTime(TimeValue.milliseconds(100)) .measurementIterations(1) .warmupIterations(3) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/000077500000000000000000000000001446271450100242535ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java000066400000000000000000000042121446271450100272270ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.annsteal; import org.junit.Test; import org.junit.Assert; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.util.FileUtils; import java.io.IOException; import java.io.InputStream; import java.util.Collection; @CustomAnnotation // here! public class CustomTest { @Benchmark public void bench() { // intentionally left blank } @Test public void test() throws IOException { if (!"default".equals(System.getProperty("jmh.core.it.profile"))) { return; } InputStream list = CustomTest.class.getResourceAsStream('/' + CustomBenchmarkProcessor.CBP_LIST); if (list == null) { throw new IllegalStateException(CustomBenchmarkProcessor.class.getSimpleName() + " list is not found"); } Collection strings = FileUtils.readAllLines(list); Assert.assertTrue(strings.contains(CustomTest.class.getSimpleName())); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/000077500000000000000000000000001446271450100235745ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/ExactThreadCountTest.java000066400000000000000000000067761446271450100305240ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.asymm; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) @Fork(1) public class ExactThreadCountTest { private final Set test1threads = Collections.synchronizedSet(new HashSet<>()); private final Set test2threads = Collections.synchronizedSet(new HashSet<>()); @Setup(Level.Iteration) public void setup() { test1threads.clear(); test2threads.clear(); } @TearDown(Level.Iteration) public void check() { Assert.assertEquals(1, test1threads.size()); Assert.assertEquals(2, test2threads.size()); } @Benchmark @Group("test") @GroupThreads(1) public void test1() { test1threads.add(Thread.currentThread()); Fixtures.work(); } @Benchmark @Group("test") @GroupThreads(2) public void test2() { test2threads.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())+".*test") .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java000066400000000000000000000057451446271450100304530ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.asymm; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) @Fork(1) public class Zero1ThreadCountTest { private final Set test1threads = Collections.synchronizedSet(new HashSet<>()); private final Set test2threads = Collections.synchronizedSet(new HashSet<>()); @TearDown public void check() { Assert.assertEquals(0, test1threads.size()); if (Fixtures.expectStableThreads()) { Assert.assertEquals(2, test2threads.size()); } else { Assert.assertTrue(test2threads.size() >= 2); } } @Benchmark @Group("test") @GroupThreads(0) public void test1() { test1threads.add(Thread.currentThread()); Fixtures.work(); } @Benchmark @Group("test") @GroupThreads(2) public void test2() { test2threads.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".*test") .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java000066400000000000000000000066501446271450100304500ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.asymm; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) @Fork(1) public class Zero2ThreadCountTest { private final Set test1threads = Collections.synchronizedSet(new HashSet<>()); private final Set test2threads = Collections.synchronizedSet(new HashSet<>()); @TearDown public void check() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(1, test1threads.size()); } else { Assert.assertTrue(test1threads.size() >= 1); } Assert.assertEquals(0, test2threads.size()); } @Benchmark @Group("test") @GroupThreads(1) public void test1() { test1threads.add(Thread.currentThread()); Fixtures.work(); } @Benchmark @Group("test") @GroupThreads(0) public void test2() { test2threads.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".*test") .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/000077500000000000000000000000001446271450100250265ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/AuxCountersEventsTest.java000066400000000000000000000072241446271450100322030ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.auxcounters; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public class AuxCountersEventsTest { @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class Counters { public int cnt; } @Benchmark public void test(Counters cnt) { if (cnt.cnt == 0) { // set event once cnt.cnt = 42; } Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .shouldFailOnError(true) .build(); RunResult result = new Runner(opts).runSingle(); Result prim = result.getPrimaryResult(); Result scnd = result.getSecondaryResults().get("cnt"); switch (mode) { case Throughput: case AverageTime: case SampleTime: case SingleShotTime: { Assert.assertNotNull("@AuxCounter result exists for " + mode, scnd); Assert.assertEquals("#", scnd.getScoreUnit()); // Sample time is special, because it is allowed to lose the samples. if (mode != Mode.SampleTime) { Assert.assertEquals(prim.getSampleCount(), scnd.getSampleCount()); } // 5 iterations, each returns exactly 42 events Assert.assertEquals(5 * 42, scnd.getScore(), 0.001); Assert.assertEquals(Double.NaN, scnd.getScoreError(), 0.001); break; } default: { Assert.assertNull("@AuxCounter does not exist for " + mode, scnd); } } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/AuxCountersOperationsTest.java000066400000000000000000000065761446271450100330730ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.auxcounters; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public class AuxCountersOperationsTest { @AuxCounters(AuxCounters.Type.OPERATIONS) @State(Scope.Thread) public static class Counters { public int cnt; } @Benchmark public void test(Counters cnt) { cnt.cnt++; Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .shouldFailOnError(true) .build(); RunResult result = new Runner(opts).runSingle(); Result prim = result.getPrimaryResult(); Result scnd = result.getSecondaryResults().get("cnt"); switch (mode) { case Throughput: case AverageTime: { Assert.assertNotNull("@AuxCounter result exists for " + mode, scnd); // Should match primary metric exactly. Assert.assertEquals(prim.getSampleCount(), scnd.getSampleCount()); Assert.assertEquals(prim.getScoreUnit(), scnd.getScoreUnit()); Assert.assertEquals(prim.getScore(), scnd.getScore(), 0.001); Assert.assertEquals(prim.getScoreError(), scnd.getScoreError(), 0.001); break; } default: { Assert.assertNull("@AuxCounter does not exist for " + mode, scnd); } } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/000077500000000000000000000000001446271450100244225ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java000066400000000000000000000112761446271450100312000ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.batchsize; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Map; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class BatchSizeSanityTest { private static final int SLEEP_TIME_MS = 50; @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class TimeCounter { public long time; } @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class OpsCounter { public int ops; } private long startTime; @Setup(Level.Iteration) public void setup() { startTime = System.nanoTime(); } @TearDown(Level.Iteration) public void tearDown(TimeCounter cnt) { cnt.time = System.nanoTime() - startTime; } @Benchmark public void test(OpsCounter cnt) throws InterruptedException { TimeUnit.MILLISECONDS.sleep(SLEEP_TIME_MS); cnt.ops++; } @Test public void invokeAPI() throws RunnerException { for (int bs : new int[] {1, 10, 100}) { for (Mode m : Mode.values()) { if (m == Mode.All) continue; doWith(m, bs); } } } private void doWith(Mode mode, int batchSize) throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupIterations(0) .measurementTime(TimeValue.seconds(1)) .measurementIterations(5) .forks(1) .timeUnit(TimeUnit.MILLISECONDS) .syncIterations(false) .measurementBatchSize(batchSize) .mode(mode) .build(); RunResult run = new Runner(opt).runSingle(); final double TOLERANCE = 0.30; Map srs = run.getSecondaryResults(); Assert.assertNotNull("Ops counter is available for " + mode, srs.get("ops")); Assert.assertNotNull("Time counter is available for " + mode, srs.get("time")); double realOps = srs.get("ops").getScore(); double realTime = srs.get("time").getScore() / 1_000_000; double actualScore = run.getPrimaryResult().getStatistics().getMean(); double expectedScore; switch (mode) { case Throughput: expectedScore = 1.0 * (1.0 * realOps / batchSize) / realTime; break; case AverageTime: case SampleTime: case SingleShotTime: expectedScore = 1.0 * realTime / (1.0 * realOps / batchSize); break; default: expectedScore = Double.NaN; actualScore = Double.NaN; Assert.fail("Unhandled mode: " + mode); } Assert.assertTrue( String.format("mode = %s, batch size = %d, expected score = %e, actual score = %e; real time = %.5f, real ops = %.5f", mode, batchSize, expectedScore, actualScore, realTime, realOps), Math.abs(1 - actualScore / expectedScore) < TOLERANCE); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java000066400000000000000000000112651446271450100312070ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.batchsize; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Map; import java.util.concurrent.TimeUnit; @State(Scope.Thread) public class OpsPerInvSanityTest { private static final int SLEEP_TIME_MS = 50; @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class TimeCounter { public long time; } @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) public static class OpsCounter { public int ops; } private long startTime; @Setup(Level.Iteration) public void setup() { startTime = System.nanoTime(); } @TearDown(Level.Iteration) public void tearDown(TimeCounter cnt) { cnt.time = System.nanoTime() - startTime; } @Benchmark public void test(OpsCounter cnt) throws InterruptedException { TimeUnit.MILLISECONDS.sleep(SLEEP_TIME_MS); cnt.ops++; } @Test public void invokeAPI() throws RunnerException { for (int opsPerInv : new int[] {1, 10, 100}) { for (Mode m : Mode.values()) { if (m == Mode.All) continue; doWith(m, opsPerInv); } } } private void doWith(Mode mode, int opsPerInv) throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupIterations(0) .measurementTime(TimeValue.seconds(1)) .measurementIterations(5) .forks(1) .timeUnit(TimeUnit.MILLISECONDS) .syncIterations(false) .operationsPerInvocation(opsPerInv) .mode(mode) .build(); RunResult run = new Runner(opt).runSingle(); final double TOLERANCE = 0.30; Map srs = run.getSecondaryResults(); Assert.assertNotNull("Ops counter is available for " + mode, srs.get("ops")); Assert.assertNotNull("Time counter is available for " + mode, srs.get("time")); double realOps = srs.get("ops").getScore(); double realTime = srs.get("time").getScore() / 1_000_000; double actualScore = run.getPrimaryResult().getStatistics().getMean(); double expectedScore; switch (mode) { case Throughput: expectedScore = 1.0 * (realOps * opsPerInv) / realTime; break; case AverageTime: case SampleTime: case SingleShotTime: expectedScore = 1.0 * realTime / (realOps * opsPerInv); break; default: expectedScore = Double.NaN; actualScore = Double.NaN; Assert.fail("Unhandled mode: " + mode); } Assert.assertTrue( String.format("mode = %s, ops per inv = %d, expected score = %e, actual score = %e; real time = %.5f, real ops = %.5f", mode, opsPerInv, expectedScore, actualScore, realTime, realOps), Math.abs(1 - actualScore / expectedScore) < TOLERANCE); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/SingleShotBatchAnn05Test.java000066400000000000000000000076451446271450100317640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.batchsize; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness honors batch size annotation settings. */ @State(Scope.Thread) public class SingleShotBatchAnn05Test { private static final int WARMUP_ITERATIONS = 2; private static final int MEASUREMENT_ITERATIONS = 1; private static final int WARMUP_BATCH = 0; private static final int MEASUREMENT_BATCH = 5; private final AtomicInteger iterationCount = new AtomicInteger(); private final AtomicInteger batchCount = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { iterationCount.incrementAndGet(); batchCount.set(0); } private boolean isWarmup() { return iterationCount.get() <= WARMUP_ITERATIONS; } @TearDown(Level.Iteration) public void tearDownIter() { if(isWarmup()) { Assert.assertEquals(WARMUP_BATCH + " batch size expected", WARMUP_BATCH, batchCount.get()); } else { Assert.assertEquals(MEASUREMENT_BATCH + " batch size expected", MEASUREMENT_BATCH, batchCount.get()); } } @TearDown public void tearDownTrial() { Assert.assertEquals((MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS)+" iterations expected", (MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS), iterationCount.get()); } @Benchmark @Warmup(iterations = WARMUP_ITERATIONS, batchSize = WARMUP_BATCH) @Measurement(iterations = MEASUREMENT_ITERATIONS, batchSize = MEASUREMENT_BATCH) @BenchmarkMode(Mode.SingleShotTime) @Fork(1) public void test() { Fixtures.work(); batchCount.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/SingleShotBatchAnn15Test.java000066400000000000000000000075101446271450100317540ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.batchsize; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness honors batch size annotation settings. */ @State(Scope.Thread) public class SingleShotBatchAnn15Test { private static final int WARMUP_ITERATIONS = 2; private static final int MEASUREMENT_ITERATIONS = 1; private static final int WARMUP_BATCH = 1; private static final int MEASUREMENT_BATCH = 5; private final AtomicInteger iterationCount = new AtomicInteger(); private final AtomicInteger batchCount = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { iterationCount.incrementAndGet(); batchCount.set(0); } private boolean isWarmup() { return iterationCount.get() <= WARMUP_ITERATIONS; } @TearDown(Level.Iteration) public void tearDownIter() { if(isWarmup()) { Assert.assertEquals(WARMUP_BATCH + " batch size expected", WARMUP_BATCH, batchCount.get()); } else { Assert.assertEquals(MEASUREMENT_BATCH + " batch size expected", MEASUREMENT_BATCH, batchCount.get()); } } @TearDown public void tearDownTrial() { Assert.assertEquals((MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS)+" iterations expected", (MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS), iterationCount.get()); } @Benchmark @Warmup(iterations = WARMUP_ITERATIONS, batchSize = WARMUP_BATCH) @Measurement(iterations = MEASUREMENT_ITERATIONS, batchSize = MEASUREMENT_BATCH) @BenchmarkMode(Mode.SingleShotTime) @Fork(1) public void test() { Fixtures.work(); batchCount.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/SingleShotBatchAnn56Test.java000066400000000000000000000075101446271450100317610ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.batchsize; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness honors batch size annotation settings. */ @State(Scope.Thread) public class SingleShotBatchAnn56Test { private static final int WARMUP_ITERATIONS = 2; private static final int MEASUREMENT_ITERATIONS = 1; private static final int WARMUP_BATCH = 1; private static final int MEASUREMENT_BATCH = 5; private final AtomicInteger iterationCount = new AtomicInteger(); private final AtomicInteger batchCount = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { iterationCount.incrementAndGet(); batchCount.set(0); } private boolean isWarmup() { return iterationCount.get() <= WARMUP_ITERATIONS; } @TearDown(Level.Iteration) public void tearDownIter() { if(isWarmup()) { Assert.assertEquals(WARMUP_BATCH + " batch size expected", WARMUP_BATCH, batchCount.get()); } else { Assert.assertEquals(MEASUREMENT_BATCH + " batch size expected", MEASUREMENT_BATCH, batchCount.get()); } } @TearDown public void tearDownTrial() { Assert.assertEquals((MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS)+" iterations expected", (MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS), iterationCount.get()); } @Benchmark @Warmup(iterations = WARMUP_ITERATIONS, batchSize = WARMUP_BATCH) @Measurement(iterations = MEASUREMENT_ITERATIONS, batchSize = MEASUREMENT_BATCH) @BenchmarkMode(Mode.SingleShotTime) @Fork(1) public void test() { Fixtures.work(); batchCount.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/SingleShotBatchApi05Test.java000066400000000000000000000067201446271450100317520ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.batchsize; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness honors batch size annotation settings. */ @State(Scope.Thread) public class SingleShotBatchApi05Test { private static final int WARMUP_ITERATIONS = 2; private static final int MEASUREMENT_ITERATIONS = 1; private static final int WARMUP_BATCH = 1; private static final int MEASUREMENT_BATCH = 5; private final AtomicInteger iterationCount = new AtomicInteger(); private final AtomicInteger batchCount = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { iterationCount.incrementAndGet(); batchCount.set(0); } private boolean isWarmup() { return iterationCount.get() <= WARMUP_ITERATIONS; } @TearDown(Level.Iteration) public void tearDownIter() { if(isWarmup()) { Assert.assertEquals(WARMUP_BATCH + " batch size expected", WARMUP_BATCH, batchCount.get()); } else { Assert.assertEquals(MEASUREMENT_BATCH + " batch size expected", MEASUREMENT_BATCH, batchCount.get()); } } @TearDown public void tearDownTrial() { Assert.assertEquals((MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS)+" iterations expected", (MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS), iterationCount.get()); } @Benchmark @Fork(1) public void test() { Fixtures.work(); batchCount.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupIterations(WARMUP_ITERATIONS) .warmupBatchSize(WARMUP_BATCH) .measurementIterations(MEASUREMENT_ITERATIONS) .measurementBatchSize(MEASUREMENT_BATCH) .mode(Mode.SingleShotTime) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/SingleShotBatchApi15Test.java000066400000000000000000000073771446271450100317640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.batchsize; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness honors batch size annotation settings. */ @State(Scope.Thread) public class SingleShotBatchApi15Test { private static final int WARMUP_ITERATIONS = 2; private static final int MEASUREMENT_ITERATIONS = 1; private static final int WARMUP_BATCH = 1; private static final int MEASUREMENT_BATCH = 5; private final AtomicInteger iterationCount = new AtomicInteger(); private final AtomicInteger batchCount = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { iterationCount.incrementAndGet(); batchCount.set(0); } private boolean isWarmup() { return iterationCount.get() <= WARMUP_ITERATIONS; } @TearDown(Level.Iteration) public void tearDownIter() { if(isWarmup()) { Assert.assertEquals(WARMUP_BATCH + " batch size expected", WARMUP_BATCH, batchCount.get()); } else { Assert.assertEquals(MEASUREMENT_BATCH + " batch size expected", MEASUREMENT_BATCH, batchCount.get()); } } @TearDown public void tearDownTrial() { Assert.assertEquals((MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS)+" iterations expected", (MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS), iterationCount.get()); } @Benchmark @Fork(1) public void test() { Fixtures.work(); batchCount.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupIterations(WARMUP_ITERATIONS) .warmupBatchSize(WARMUP_BATCH) .measurementIterations(MEASUREMENT_ITERATIONS) .measurementBatchSize(MEASUREMENT_BATCH) .mode(Mode.SingleShotTime) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/SingleShotBatchApi67Test.java000066400000000000000000000073771446271450100317730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.batchsize; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness honors batch size annotation settings. */ @State(Scope.Thread) public class SingleShotBatchApi67Test { private static final int WARMUP_ITERATIONS = 2; private static final int MEASUREMENT_ITERATIONS = 1; private static final int WARMUP_BATCH = 6; private static final int MEASUREMENT_BATCH = 7; private final AtomicInteger iterationCount = new AtomicInteger(); private final AtomicInteger batchCount = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { iterationCount.incrementAndGet(); batchCount.set(0); } private boolean isWarmup() { return iterationCount.get() <= WARMUP_ITERATIONS; } @TearDown(Level.Iteration) public void tearDownIter() { if(isWarmup()) { Assert.assertEquals(WARMUP_BATCH + " batch size expected", WARMUP_BATCH, batchCount.get()); } else { Assert.assertEquals(MEASUREMENT_BATCH + " batch size expected", MEASUREMENT_BATCH, batchCount.get()); } } @TearDown public void tearDownTrial() { Assert.assertEquals((MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS)+" iterations expected", (MEASUREMENT_ITERATIONS+WARMUP_ITERATIONS), iterationCount.get()); } @Benchmark @Fork(1) public void test() { Fixtures.work(); batchCount.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupIterations(WARMUP_ITERATIONS) .warmupBatchSize(WARMUP_BATCH) .measurementIterations(MEASUREMENT_ITERATIONS) .measurementBatchSize(MEASUREMENT_BATCH) .mode(Mode.SingleShotTime) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/000077500000000000000000000000001446271450100246375ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java000066400000000000000000000106761446271450100312310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.bulkwarmup; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.WarmupMode; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import static org.junit.Assert.assertEquals; @State(Scope.Thread) public class NonForkedModesTest { private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; @Setup(Level.Iteration) public void oneShot() { recorded = false; } @Benchmark public void testBig(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("W"); break; case MEASUREMENT: testSequence.add("I"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } @Benchmark public void testSmall(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("w"); break; case MEASUREMENT: testSequence.add("i"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } private static String getSequence() { StringBuilder sb = new StringBuilder(); for (String s : testSequence) { sb.append(s); } return sb.toString(); } @Test public void invokeINDI() throws RunnerException { testWith(WarmupMode.INDI, "WIwi"); } @Test public void invokeBULK() throws RunnerException { testWith(WarmupMode.BULK, "WwIi"); } @Test public void invokeBULK_INDI() throws RunnerException { testWith(WarmupMode.BULK_INDI, "WwWIwi"); } public void testWith(WarmupMode mode, String runSeq) throws RunnerException { testSequence.clear(); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupIterations(1) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(200)) .threads(1) .forks(0) .syncIterations(false) .warmupMode(mode) .build(); new Runner(opt).run(); assertEquals(runSeq, getSequence()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java000066400000000000000000000101461446271450100306430ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.bulkwarmup; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: * -wmb * -wm * -frw * .... */ @State(Scope.Thread) public class WarmupMode0_Test { private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; @Setup(Level.Iteration) public void oneShot() { recorded = false; } @Benchmark public void testBig(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("W"); break; case MEASUREMENT: testSequence.add("I"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } @Benchmark public void testSmall(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("w"); break; case MEASUREMENT: testSequence.add("i"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } private static String getSequence() { StringBuilder sb = new StringBuilder(); for (String s : testSequence) { sb.append(s); } return sb.toString(); } @Test public void invokeAPI() throws RunnerException { testSequence.clear(); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".testBig.*") .shouldFailOnError(true) .warmupIterations(2) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(200)) .threads(1) .forks(0) .syncIterations(false) .build(); new Runner(opt).run(); assertEquals("WWI", getSequence()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java000066400000000000000000000101501446271450100306370ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.bulkwarmup; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: * -wmb * -wm * -frw * .... */ @State(Scope.Thread) public class WarmupMode1_Test { private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; @Setup(Level.Iteration) public void oneShot() { recorded = false; } @Benchmark public void testBig(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("W"); break; case MEASUREMENT: testSequence.add("I"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } @Benchmark public void testSmall(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("w"); break; case MEASUREMENT: testSequence.add("i"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } private static String getSequence() { StringBuilder sb = new StringBuilder(); for (String s : testSequence) { sb.append(s); } return sb.toString(); } @Test public void invokeAPI() throws RunnerException { testSequence.clear(); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".testSmall.*") .shouldFailOnError(true) .warmupIterations(2) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(200)) .threads(1) .forks(0) .syncIterations(false) .build(); new Runner(opt).run(); assertEquals("wwi", getSequence()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java000066400000000000000000000101511446271450100306410ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.bulkwarmup; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: * -wmb * -wm * -frw * .... */ @State(Scope.Thread) public class WarmupMode2_Test { private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; @Setup(Level.Iteration) public void oneShot() { recorded = false; } @Benchmark public void testBig(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("W"); break; case MEASUREMENT: testSequence.add("I"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } @Benchmark public void testSmall(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("w"); break; case MEASUREMENT: testSequence.add("i"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } private static String getSequence() { StringBuilder sb = new StringBuilder(); for (String s : testSequence) { sb.append(s); } return sb.toString(); } @Test public void invokeAPI() throws RunnerException { testSequence.clear(); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".testBig.*") .shouldFailOnError(true) .warmupIterations(2) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(200)) .threads(2) .forks(0) .syncIterations(false) .build(); new Runner(opt).run(); assertEquals("WWWWII", getSequence()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java000066400000000000000000000101371446271450100306460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.bulkwarmup; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: * -wmb * -wm * -frw * .... */ @State(Scope.Thread) public class WarmupMode3_Test { private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; @Setup(Level.Iteration) public void oneShot() { recorded = false; } @Benchmark public void testBig(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("W"); break; case MEASUREMENT: testSequence.add("I"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } @Benchmark public void testSmall(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("w"); break; case MEASUREMENT: testSequence.add("i"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } private static String getSequence() { StringBuilder sb = new StringBuilder(); for (String s : testSequence) { sb.append(s); } return sb.toString(); } @Test public void invokeAPI() throws RunnerException { testSequence.clear(); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupIterations(2) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(200)) .threads(2) .forks(0) .syncIterations(false) .build(); new Runner(opt).run(); assertEquals("WWWWIIwwwwii", getSequence()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java000066400000000000000000000101321446271450100306420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.bulkwarmup; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: * -wmb * -wm * -frw * .... */ @State(Scope.Thread) public class WarmupMode4_Test { private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; @Setup(Level.Iteration) public void oneShot() { recorded = false; } @Benchmark public void testBig(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("W"); break; case MEASUREMENT: testSequence.add("I"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } @Benchmark public void testSmall(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("w"); break; case MEASUREMENT: testSequence.add("i"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } private static String getSequence() { StringBuilder sb = new StringBuilder(); for (String s : testSequence) { sb.append(s); } return sb.toString(); } @Test public void invokeAPI() throws RunnerException { testSequence.clear(); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupIterations(2) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(200)) .threads(1) .forks(0) .syncIterations(false) .build(); new Runner(opt).run(); assertEquals("WWIwwi", getSequence()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java000066400000000000000000000102711446271450100306470ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.bulkwarmup; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.WarmupMode; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: * -wmb * -wm * -frw * .... */ @State(Scope.Thread) public class WarmupMode5_Test { private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; @Setup(Level.Iteration) public void oneShot() { recorded = false; } @Benchmark public void testBig(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("W"); break; case MEASUREMENT: testSequence.add("I"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } @Benchmark public void testSmall(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("w"); break; case MEASUREMENT: testSequence.add("i"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } private static String getSequence() { StringBuilder sb = new StringBuilder(); for (String s : testSequence) { sb.append(s); } return sb.toString(); } @Test public void invokeAPI() throws RunnerException { testSequence.clear(); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupIterations(2) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(200)) .threads(1) .forks(0) .syncIterations(false) .warmupMode(WarmupMode.INDI) .build(); new Runner(opt).run(); assertEquals("WWIwwi", getSequence()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java000066400000000000000000000102711446271450100306500ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.bulkwarmup; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.WarmupMode; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: * -wmb * -wm * -frw * .... */ @State(Scope.Thread) public class WarmupMode6_Test { private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; @Setup(Level.Iteration) public void oneShot() { recorded = false; } @Benchmark public void testBig(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("W"); break; case MEASUREMENT: testSequence.add("I"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } @Benchmark public void testSmall(IterationParams params) { if (!recorded) { recorded = true; switch (params.getType()) { case WARMUP: testSequence.add("w"); break; case MEASUREMENT: testSequence.add("i"); break; default: throw new IllegalStateException(params.getType().toString()); } } Fixtures.work(); } private static String getSequence() { StringBuilder sb = new StringBuilder(); for (String s : testSequence) { sb.append(s); } return sb.toString(); } @Test public void invokeAPI() throws RunnerException { testSequence.clear(); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .warmupIterations(2) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(200)) .threads(1) .forks(0) .syncIterations(false) .warmupMode(WarmupMode.BULK) .build(); new Runner(opt).run(); assertEquals("WWwwIi", getSequence()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/000077500000000000000000000000001446271450100242715ustar00rootroot00000000000000CompilerControlDontInlineActualTest.java000066400000000000000000000067261446271450100341610ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Collection; public class CompilerControlDontInlineActualTest { @CompilerControl(CompilerControl.Mode.DONT_INLINE) public void strawMethod() { } public void trampoline() { strawMethod(); } @Benchmark @CompilerControl(CompilerControl.Mode.DONT_INLINE) public void compilerControlSpecimen() { trampoline(); } @Test public void testBenchmark() throws RunnerException { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .shouldFailOnError(true) .addProfiler(LogConsumeProfiler.class) .measurementIterations(mode == Mode.SingleShotTime ? 200_000 : 1) .measurementTime(TimeValue.seconds(5)) .warmupIterations(0) .forks(1) .jvmArgsPrepend("-XX:CICompilerCount=2") // need to serialize the output properly .build(); RunResult runResult = new Runner(opts).runSingle(); Collection log = CompilerControlUtils.getLog(runResult); if (CompilerControlUtils.check(log, "@", "callee")) { // Poor man's check -XX:+PrintInlining works Assert.assertTrue("Failed with " + mode, CompilerControlUtils.check(log, this.getClass().getName() + "::compilerControlSpecimen", "disallowed by")); Assert.assertTrue("Failed with " + mode, CompilerControlUtils.check(log, this.getClass().getName() + "::strawMethod", "disallowed by")); } } } } CompilerControlDontInlineClassTest.java000066400000000000000000000040571446271450100340100ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.CompilerControl.Mode; import org.openjdk.jmh.runner.RunnerException; @CompilerControl(Mode.DONT_INLINE) public class CompilerControlDontInlineClassTest { @Benchmark public void compilerControlSpecimen() {} @Test public void test() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Class hint should exist", CompilerControlUtils.hasHint(Mode.DONT_INLINE.command(), className) ); Assert.assertFalse("Method hint should not exist", CompilerControlUtils.hasHint("", className, "compilerControlSpecimen") ); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineTest.java000066400000000000000000000045141446271450100330770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.CompilerControl.Mode; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; public class CompilerControlDontInlineTest { @CompilerControl(Mode.DONT_INLINE) void sampleMethod() {} @Benchmark @CompilerControl(Mode.DONT_INLINE) public void dummyTest() { Fixtures.work(); } @Test public void testBenchmark() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Has hint on benchmark method", CompilerControlUtils.hasHint(Mode.DONT_INLINE.command(), className, "dummyTest")); } @Test public void testStandalone() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Has hint on standalone method", CompilerControlUtils.hasHint(Mode.DONT_INLINE.command(), className, "sampleMethod")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeActualTest.java000066400000000000000000000100101446271450100335430ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Collection; public class CompilerControlExcludeActualTest { @CompilerControl(CompilerControl.Mode.EXCLUDE) public void strawMethod() { } public void trampoline() { strawMethod(); } @Benchmark @CompilerControl(CompilerControl.Mode.EXCLUDE) public void compilerControlSpecimen() { trampoline(); } @Test public void testBenchmark() throws RunnerException { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .shouldFailOnError(true) .addProfiler(LogConsumeProfiler.class) .measurementIterations(mode == Mode.SingleShotTime ? 200_000 : 1) .measurementTime(TimeValue.seconds(5)) .warmupIterations(0) .forks(1) .jvmArgsPrepend("-XX:CICompilerCount=2") // need to serialize the output properly .build(); RunResult runResult = new Runner(opts).runSingle(); Collection log = CompilerControlUtils.getLog(runResult); if (CompilerControlUtils.check(log, "@", "callee")) { // Poor man's check -XX:+PrintInlining works Assert.assertTrue("Failed with " + mode, CompilerControlUtils.check(log, this.getClass().getName() + "::compilerControlSpecimen", "excluded by") || CompilerControlUtils.check(log, this.getClass().getName() + "::compilerControlSpecimen", "not compilable") || CompilerControlUtils.check(log, this.getClass().getName() + "::compilerControlSpecimen", "disallowed by CompileCommand") ); Assert.assertTrue("Failed with " + mode, CompilerControlUtils.check(log, this.getClass().getName() + "::strawMethod", "excluded by") || CompilerControlUtils.check(log, this.getClass().getName() + "::strawMethod", "not compilable") || CompilerControlUtils.check(log, this.getClass().getName() + "::strawMethod", "disallowed by CompileCommand") ); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeClassTest.java000066400000000000000000000040441446271450100334110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.CompilerControl.Mode; import org.openjdk.jmh.runner.RunnerException; @CompilerControl(Mode.EXCLUDE) public class CompilerControlExcludeClassTest { @Benchmark public void compilerControlSpecimen() {} @Test public void test() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Class hint should exist", CompilerControlUtils.hasHint(Mode.EXCLUDE.command(), className) ); Assert.assertFalse("Method hint should not exist", CompilerControlUtils.hasHint("", className, "compilerControlSpecimen") ); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeTest.java000066400000000000000000000044711446271450100324270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.CompilerControl.Mode; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; public class CompilerControlExcludeTest { @CompilerControl(Mode.EXCLUDE) void sampleMethod() {} @Benchmark @CompilerControl(Mode.EXCLUDE) public void dummyTest() { Fixtures.work(); } @Test public void testBenchmark() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Has hint on benchmark method", CompilerControlUtils.hasHint(Mode.EXCLUDE.command(), className, "dummyTest")); } @Test public void testStandalone() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Has hint on standalone method", CompilerControlUtils.hasHint(Mode.EXCLUDE.command(), className, "sampleMethod")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineActualTest.java000066400000000000000000000067141446271450100334100ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Collection; public class CompilerControlInlineActualTest { @CompilerControl(CompilerControl.Mode.INLINE) public void strawMethod() { } public void trampoline() { strawMethod(); } @Benchmark @CompilerControl(CompilerControl.Mode.INLINE) public void compilerControlSpecimen() { trampoline(); } @Test public void testBenchmark() throws RunnerException { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .shouldFailOnError(true) .addProfiler(LogConsumeProfiler.class) .measurementIterations(mode == Mode.SingleShotTime ? 200_000 : 1) .measurementTime(TimeValue.seconds(5)) .warmupIterations(0) .forks(1) .jvmArgsPrepend("-XX:CICompilerCount=2") // need to serialize the output properly .build(); RunResult runResult = new Runner(opts).runSingle(); Collection log = CompilerControlUtils.getLog(runResult); if (CompilerControlUtils.check(log, "@", "callee")) { // Poor man's check -XX:+PrintInlining works Assert.assertTrue("Failed with " + mode, CompilerControlUtils.check(log, this.getClass().getName() + "::compilerControlSpecimen", "force inline by")); Assert.assertTrue("Failed with " + mode, CompilerControlUtils.check(log, this.getClass().getName() + "::strawMethod", "force inline by")); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineClassTest.java000066400000000000000000000040411446271450100332330ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.CompilerControl.Mode; import org.openjdk.jmh.runner.RunnerException; @CompilerControl(Mode.INLINE) public class CompilerControlInlineClassTest { @Benchmark public void compilerControlSpecimen() {} @Test public void test() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Class hint should exist", CompilerControlUtils.hasHint(Mode.INLINE.command(), className) ); Assert.assertFalse("Method hint should not exist", CompilerControlUtils.hasHint("", className, "compilerControlSpecimen") ); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineTest.java000066400000000000000000000044641446271450100322560ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.CompilerControl.Mode; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; public class CompilerControlInlineTest { @CompilerControl(Mode.INLINE) void sampleMethod() {} @Benchmark @CompilerControl(Mode.INLINE) public void dummyTest() { Fixtures.work(); } @Test public void testBenchmark() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Has hint on benchmark method", CompilerControlUtils.hasHint(Mode.INLINE.command(), className, "dummyTest")); } @Test public void testStandalone() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Has hint on standalone method", CompilerControlUtils.hasHint(Mode.INLINE.command(), className, "sampleMethod")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlNestedTest.java000066400000000000000000000047031446271450100322560ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.CompilerControl.Mode; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; public class CompilerControlNestedTest { @CompilerControl(Mode.INLINE) public static class SpecimenClass { void sampleMethod() {} } public static class SpecimenMethod { @CompilerControl(Mode.INLINE) void sampleMethod() {} } @Benchmark public void dummyTest() { Fixtures.work(); } @Test public void testClass() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Has hint on nested class", CompilerControlUtils.hasHint(Mode.INLINE.command(), className, "$SpecimenClass.*")); } @Test public void testMethod() throws RunnerException { String className = this.getClass().getName().replace(".", "/"); Assert.assertTrue("Has hint on nested class", CompilerControlUtils.hasHint(Mode.INLINE.command(), className, "$SpecimenMethod", "sampleMethod")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlUtils.java000066400000000000000000000044531446271450100312760ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.CompilerHints; import java.util.Collection; public class CompilerControlUtils { public static Collection getLog(RunResult runResult) { LogConsumeProfiler.LogConsumeResult r = (LogConsumeProfiler.LogConsumeResult) runResult.getSecondaryResults().get("logout"); return r.getLines(); } public static boolean check(Collection log, String... checkFor) { line: for (String line : log) { System.out.println(line); for (String m : checkFor) { if (!line.contains(m)) continue line; } return true; } return false; } public static boolean hasHint(String hint, String... filters) { nextHint: for (String s : CompilerHints.defaultList().get()) { for (String f : filters) { if (!s.contains(f)) continue nextHint; } if (s.startsWith(hint)) { return true; } } return false; } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/LogConsumeProfiler.java000066400000000000000000000077171446271450100307260ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.ccontrol; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.profile.ExternalProfiler; import org.openjdk.jmh.results.*; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; public class LogConsumeProfiler implements ExternalProfiler { @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public Collection addJVMOptions(BenchmarkParams params) { return Arrays.asList("-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintCompilation", "-XX:+PrintInlining"); } @Override public void beforeTrial(BenchmarkParams benchmarkParams) { } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { try { return Arrays.asList( new LogConsumeResult("out", FileUtils.readAllLines(stdOut)), new LogConsumeResult("err", FileUtils.readAllLines(stdErr)) ); } catch (IOException e) { // skip } return Collections.emptyList(); } @Override public boolean allowPrintOut() { return false; } @Override public boolean allowPrintErr() { return false; } @Override public String getDescription() { return "Log aggregating profiler"; } public static class LogConsumeResult extends Result { private final Collection lines; public LogConsumeResult(String label, Collection lines) { super(ResultRole.SECONDARY, "log" + label, of(Double.NaN), "N/A", AggregationPolicy.MAX); this.lines = lines; } public Collection getLines() { return lines; } @Override protected Aggregator getThreadAggregator() { return new LogAggregator(); } @Override protected Aggregator getIterationAggregator() { return new LogAggregator(); } public static class LogAggregator implements Aggregator { @Override public LogConsumeResult aggregate(Collection results) { String label = null; Collection allLines = new ArrayList<>(); for (LogConsumeResult r : results) { label = r.label; allLines.addAll(r.getLines()); } return new LogConsumeResult(label, allLines); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/000077500000000000000000000000001446271450100241265ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStartStopTest.java000066400000000000000000000046351446271450100311450ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.control; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Control; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) public class ControlStartStopTest { @Benchmark public void ping(Control cnt) { boolean stop = cnt.stopMeasurement; boolean start = cnt.startMeasurement; // stop should always be preceded by start Assert.assertFalse(stop && !start); } @Test public void invokeAPI() throws RunnerException { for (Mode m : Mode.values()) { if (m == Mode.All) continue; Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .mode(m) .build(); new Runner(opt).runSingle(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStopTest.java000066400000000000000000000047071446271450100301270ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.control; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Control; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) public class ControlStopTest { @Benchmark @Group("pingpong") public void ping(Control cnt) { while (!cnt.stopMeasurement) { Thread.yield(); } } @Benchmark @Group("pingpong") public void pong(Control cnt) { while (!cnt.stopMeasurement) { Thread.yield(); } } @Test public void invokeAPI() throws RunnerException { for (Mode m : Mode.values()) { if (m == Mode.All) continue; Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .mode(m) .build(); new Runner(opt).runSingle(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/000077500000000000000000000000001446271450100242355ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/BenchmarkIterationDagOrderTest.java000066400000000000000000000110251446271450100331200ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class BenchmarkIterationDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Benchmark) public static class S3 { @Setup(Level.Iteration) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S2 { @Setup(Level.Iteration) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S1 { @Setup(Level.Iteration) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/BenchmarkTrialDagOrderTest.java000066400000000000000000000107711446271450100322440ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class BenchmarkTrialDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Benchmark) public static class S3 { @Setup(Level.Trial) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S2 { @Setup(Level.Trial) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S1 { @Setup(Level.Trial) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTIterationDagOrderTest.java000066400000000000000000000100451446271450100326320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedBGTIterationDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Thread) public static class S3 { @Setup(Level.Iteration) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Group) public static class S2 { @Setup(Level.Iteration) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S1 { @Setup(Level.Iteration) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTTrialDagOrderTest.java000066400000000000000000000100111446271450100317400ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedBGTTrialDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Thread) public static class S3 { @Setup(Level.Trial) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Group) public static class S2 { @Setup(Level.Trial) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S1 { @Setup(Level.Trial) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGIterationDagOrderTest.java000066400000000000000000000100451446271450100326320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedBTGIterationDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Group) public static class S3 { @Setup(Level.Iteration) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S2 { @Setup(Level.Iteration) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S1 { @Setup(Level.Iteration) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGTrialDagOrderTest.java000066400000000000000000000100111446271450100317400ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedBTGTrialDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Group) public static class S3 { @Setup(Level.Trial) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S2 { @Setup(Level.Trial) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S1 { @Setup(Level.Trial) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTIterationDagOrderTest.java000066400000000000000000000100651446271450100326340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedGBTIterationDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Thread) public static class S3 { @Setup(Level.Iteration) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S2 { @Setup(Level.Iteration) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Group) public static class S1 { @Setup(Level.Iteration) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @GroupThreads(1) @Group public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTTrialDagOrderTest.java000066400000000000000000000100311446271450100317420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedGBTTrialDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Thread) public static class S3 { @Setup(Level.Trial) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S2 { @Setup(Level.Trial) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Group) public static class S1 { @Setup(Level.Trial) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @GroupThreads(1) @Group public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBIterationDagOrderTest.java000066400000000000000000000100651446271450100326340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedGTBIterationDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Benchmark) public static class S3 { @Setup(Level.Iteration) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S2 { @Setup(Level.Iteration) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Group) public static class S1 { @Setup(Level.Iteration) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @GroupThreads(1) @Group public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBTrialDagOrderTest.java000066400000000000000000000100311446271450100317420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedGTBTrialDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Benchmark) public static class S3 { @Setup(Level.Trial) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S2 { @Setup(Level.Trial) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Group) public static class S1 { @Setup(Level.Trial) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @GroupThreads(1) @Group public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGIterationDagOrderTest.java000066400000000000000000000100451446271450100326320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedTBGIterationDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Group) public static class S3 { @Setup(Level.Iteration) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S2 { @Setup(Level.Iteration) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S1 { @Setup(Level.Iteration) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGTrialDagOrderTest.java000066400000000000000000000100111446271450100317400ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedTBGTrialDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Group) public static class S3 { @Setup(Level.Trial) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Benchmark) public static class S2 { @Setup(Level.Trial) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S1 { @Setup(Level.Trial) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBIterationDagOrderTest.java000066400000000000000000000100451446271450100326320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedTGBIterationDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Benchmark) public static class S3 { @Setup(Level.Iteration) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Group) public static class S2 { @Setup(Level.Iteration) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S1 { @Setup(Level.Iteration) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBTrialDagOrderTest.java000066400000000000000000000100111446271450100317400ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class MixedTGBTrialDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Benchmark) public static class S3 { @Setup(Level.Trial) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Group) public static class S2 { @Setup(Level.Trial) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S1 { @Setup(Level.Trial) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/ThreadIterationDagOrderTest.java000066400000000000000000000110111446271450100324300ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class ThreadIterationDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Thread) public static class S3 { @Setup(Level.Iteration) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S2 { @Setup(Level.Iteration) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S1 { @Setup(Level.Iteration) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/ThreadTrialDagOrderTest.java000066400000000000000000000107551446271450100315630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.dagorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class ThreadTrialDagOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private static volatile int s1setup, s1teardown; private static volatile int s2setup, s2teardown; private static volatile int s3setup, s3teardown; private static volatile int run; @State(Scope.Thread) public static class S3 { @Setup(Level.Trial) public void setupInstance() { s3setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s3teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S2 { @Setup(Level.Trial) public void setupInstance(S3 s3) { s2setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s2teardown = TICKER.incrementAndGet(); } } @State(Scope.Thread) public static class S1 { @Setup(Level.Trial) public void setupInstance(S2 s2) { s1setup = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { s1teardown = TICKER.incrementAndGet(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(0) @Threads(1) public void test(S1 state) { run = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); Assert.assertTrue(s1setup + " < " + run, s1setup < run); Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/000077500000000000000000000000001446271450100237625ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedErrorsTest.java000066400000000000000000000062161446271450100303600ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class EmbeddedErrorsTest { @Benchmark public void test00_normal() throws InterruptedException { Thread.sleep(1); } @Benchmark public void test01_exceptional() { throw new IllegalStateException(); } @Benchmark public void test02_normal() throws InterruptedException { Thread.sleep(1); } // Embedded runs can not possibly survive either System.exit, or VM crash @Test public void test_FOE_false() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .forks(0) .shouldFailOnError(false) .build(); Collection results = new Runner(opt).run(); Assert.assertEquals(2, results.size()); } @Test public void test_FOE_true() throws RunnerException { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .forks(0) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have thrown the exception"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowExceptionTest.java000066400000000000000000000047741446271450100320750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class EmbeddedThrowExceptionTest { @Benchmark public void bench() throws MyException { throw new MyException("Something wicked"); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), false, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "MyException")); Assert.assertTrue(Shared.contains(lines, "Something wicked")); } public static class MyException extends Exception { public MyException(String s) { super(s); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowRuntimeExceptionTest.java000066400000000000000000000047671446271450100334430ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class EmbeddedThrowRuntimeExceptionTest { @Benchmark public void bench() { throw new MyException("Something wicked"); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), false, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "MyException")); Assert.assertTrue(Shared.contains(lines, "Something wicked")); } public static class MyException extends RuntimeException { public MyException(String s) { super(s); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedErrorsTest.java000066400000000000000000000104571446271450100301030ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import sun.misc.Unsafe; import java.lang.reflect.Field; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class ForkedErrorsTest { @Benchmark public void test00_normal() throws InterruptedException { Thread.sleep(1); } @Benchmark public void test01_exceptional() { throw new IllegalStateException(); } @Benchmark public void test02_normal() throws InterruptedException { Thread.sleep(1); } @Benchmark public void test03_exit() throws InterruptedException { System.exit(1); } @Benchmark public void test04_normal() throws InterruptedException { Thread.sleep(1); } private static Unsafe getUnsafe() throws NoSuchFieldException, IllegalAccessException { Field f = Unsafe.class.getDeclaredField("theUnsafe"); f.setAccessible(true); return (Unsafe) f.get(null); } @Benchmark public void test05_crash() throws InterruptedException, NoSuchFieldException, IllegalAccessException { // SIGSEGV in JVM getUnsafe().getInt(0); } @Benchmark public void test06_normal() throws InterruptedException { Thread.sleep(1); } @Benchmark public void test07_runtimeExit() throws InterruptedException { Runtime.getRuntime().exit(1); } @Benchmark public void test08_normal() throws InterruptedException { Thread.sleep(1); } @Benchmark public void test09_runtimeHalt() throws InterruptedException { Runtime.getRuntime().halt(1); } @Benchmark public void test10_normal() throws InterruptedException { Thread.sleep(1); } @Test public void test_FOE_false() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .forks(1) .shouldFailOnError(false) .build(); Collection results = new Runner(opt).run(); Assert.assertEquals(6, results.size()); } @Test public void test_FOE_true() throws RunnerException { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .forks(1) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have thrown the exception"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit0Test.java000066400000000000000000000044731446271450100276210ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class ForkedExit0Test { @Benchmark public void bench() throws InterruptedException { System.exit(0); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "VM prematurely exited before JMH had finished with it")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit1Test.java000066400000000000000000000046231446271450100276170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class ForkedExit1Test { @Benchmark public void bench() throws InterruptedException { System.exit(1); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "forked VM failed with exit code 1")); Assert.assertTrue(Shared.contains(lines, "VM prematurely exited before JMH had finished with it")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit42Test.java000066400000000000000000000046261446271450100277070ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class ForkedExit42Test { @Benchmark public void bench() throws InterruptedException { System.exit(42); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "forked VM failed with exit code 42")); Assert.assertTrue(Shared.contains(lines, "VM prematurely exited before JMH had finished with it")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt1Test.java000066400000000000000000000044651446271450100276020ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class ForkedHalt1Test { @Benchmark public void bench() throws InterruptedException { Runtime.getRuntime().halt(1); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "forked VM failed with exit code 1")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt42Test.java000066400000000000000000000044701446271450100276630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class ForkedHalt42Test { @Benchmark public void bench() throws InterruptedException { Runtime.getRuntime().halt(42); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "forked VM failed with exit code 42")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedStuckShutdownHookTest.java000066400000000000000000000051111446271450100322640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class ForkedStuckShutdownHookTest { @Setup public void setup() { Runtime.getRuntime().addShutdownHook( new Thread(() -> { try { TimeUnit.DAYS.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } }) ); } @Benchmark public void bench() throws InterruptedException { Fixtures.work(); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "expired, forcing forked VM to exit")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedStuckThreadTest.java000066400000000000000000000050151446271450100310420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class ForkedStuckThreadTest { @Setup public void setup() { Thread t = new Thread(() -> { try { TimeUnit.DAYS.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } }); t.setDaemon(false); t.start(); } @Benchmark public void bench() throws InterruptedException { Fixtures.work(); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "expired, forcing forked VM to exit")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowExceptionTest.java000066400000000000000000000047711446271450100316130ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class ForkedThrowExceptionTest { @Benchmark public void bench() throws MyException { throw new MyException("Something wicked"); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "MyException")); Assert.assertTrue(Shared.contains(lines, "Something wicked")); } public static class MyException extends Exception { public MyException(String s) { super(s); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowRuntimeExceptionTest.java000066400000000000000000000047641446271450100331610ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS) public class ForkedThrowRuntimeExceptionTest { @Benchmark public void bench() { throw new MyException("Something wicked"); } @Test public void test() throws RunnerException, IOException { File output = FileUtils.tempFile("output"); Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output); Collection lines = FileUtils.readAllLines(output); Shared.print(lines); Assert.assertTrue(Shared.contains(lines, "MyException")); Assert.assertTrue(Shared.contains(lines, "Something wicked")); } public static class MyException extends RuntimeException { public MyException(String s) { super(s); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/Shared.java000066400000000000000000000042021446271450100260310ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.errors; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.io.File; import java.util.Collection; public class Shared { static void doRun(String include, boolean forked, File output) throws RunnerException {Options opt = new OptionsBuilder() .include(include) .forks(forked ? 1 : 0) .shouldFailOnError(false) .output(output.getAbsolutePath()) .build(); new Runner(opt).run(); } static void print(Collection lines) { for (String line : lines) { System.err.println(line); } } static boolean contains(Collection lines, String s) { for (String line : lines) { if (line.contains(s)) return true; } return false; } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/000077500000000000000000000000001446271450100235445ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/AbruptFailureTest.java000066400000000000000000000053361446271450100300230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.ThreadParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 60, timeUnit = TimeUnit.SECONDS) @Fork(1) @State(Scope.Benchmark) public class AbruptFailureTest { @Benchmark @Threads(4) public void test(ThreadParams tp) { if (tp.getThreadIndex() == 0) { throw new IllegalStateException(); // fail one thread } Fixtures.work(); } @Test public void invokeAPI() { long time1 = System.nanoTime(); try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected long time2 = System.nanoTime(); long delay = TimeUnit.NANOSECONDS.toSeconds(time2 - time1); Assert.assertTrue("Delayed for too long: " + delay + "s", delay < 10); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchSetupTest.java000066400000000000000000000053511446271450100324200ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) @State(Scope.Benchmark) public class FailingBenchmarkBenchSetupTest { @Setup public void setup() { Assert.fail(); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTearDownTest.java000066400000000000000000000053711446271450100330450ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Benchmark) public class FailingBenchmarkBenchTearDownTest { @TearDown public void tearDown() { Assert.fail(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTest.java000066400000000000000000000051731446271450100314010ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Benchmark) public class FailingBenchmarkBenchTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void doTest() { Assert.fail(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkStateSetupTest.java000066400000000000000000000054661446271450100324700ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class FailingBenchmarkStateSetupTest { @State(Scope.Benchmark) public static class MyState { @Setup public void setup() { Assert.fail(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkStateTearDownTest.java000066400000000000000000000055021446271450100331020ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class FailingBenchmarkStateTearDownTest { @State(Scope.Benchmark) public static class MyState { @TearDown public void tearDown() { Assert.fail(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchStackProfilerTest.java000066400000000000000000000054271446271450100334140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.StackProfiler; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Thread) public class FailingForkedBenchStackProfilerTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void doTest() { Assert.fail(); } @Test(timeout = 60*1000) public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .addProfiler(StackProfiler.class) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchTest.java000066400000000000000000000052231446271450100307150ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Thread) public class FailingForkedBenchTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void doTest() { Assert.fail(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedSetupTest.java000066400000000000000000000054001446271450100307730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Thread) public class FailingForkedSetupTest { @Setup public void setup() { Assert.fail(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedTearDownTest.java000066400000000000000000000054141446271450100314230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Thread) public class FailingForkedTearDownTest { @TearDown public void tearDown() { Assert.fail(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchSetupTest.java000066400000000000000000000054511446271450100316230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Group) public class FailingGroupBenchSetupTest { @Setup public void setup() { Assert.fail(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Group("T") @GroupThreads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTearDownTest.java000066400000000000000000000054651446271450100322530ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Group) public class FailingGroupBenchTearDownTest { @TearDown public void tearDown() { Assert.fail(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Group("T") @GroupThreads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java000066400000000000000000000052671446271450100306070ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Group) public class FailingGroupBenchTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Group("T") @GroupThreads(4) public void doTest() { Assert.fail(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateSetupTest.java000066400000000000000000000055621446271450100316670ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class FailingGroupStateSetupTest { @State(Scope.Group) public static class MyState { @Setup public void setup() { Assert.fail(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Group("T") @GroupThreads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateTearDownTest.java000066400000000000000000000055761446271450100323170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class FailingGroupStateTearDownTest { @State(Scope.Group) public static class MyState { @TearDown public void tearDown() { Assert.fail(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Group("T") @GroupThreads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchSetupTest.java000066400000000000000000000053471446271450100317420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Thread) public class FailingThreadBenchSetupTest { @Setup public void setup() { Assert.fail(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTearDownTest.java000066400000000000000000000053631446271450100323630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Thread) public class FailingThreadBenchTearDownTest { @TearDown public void tearDown() { Assert.fail(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTest.java000066400000000000000000000051651446271450100307170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Thread) public class FailingThreadBenchTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void doTest() { Assert.fail(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadStateSetupTest.java000066400000000000000000000054601446271450100317770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class FailingThreadStateSetupTest { @State(Scope.Thread) public static class MyState { @Setup public void setup() { Assert.fail(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadStateTearDownTest.java000066400000000000000000000054741446271450100324270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class FailingThreadStateTearDownTest { @State(Scope.Thread) public static class MyState { @TearDown public void tearDown() { Assert.fail(); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/000077500000000000000000000000001446271450100252065ustar00rootroot00000000000000AbstractBenchmarkBenchSetupTest.java000066400000000000000000000053521446271450100341760ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Benchmark) @BenchmarkMode(Mode.All) public class AbstractBenchmarkBenchSetupTest extends AbstractSetupBase { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } AbstractBenchmarkBenchTearDownTest.java000066400000000000000000000053601446271450100346200ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @State(Scope.Benchmark) @BenchmarkMode(Mode.All) public class AbstractBenchmarkBenchTearDownTest extends AbstractTearDownBase { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } AbstractBenchmarkStateSetupTest.java000066400000000000000000000054401446271450100342350ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class AbstractBenchmarkStateSetupTest { @State(Scope.Benchmark) public static class MyState extends AbstractSetupBase {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } AbstractBenchmarkStateTearDownTest.java000066400000000000000000000054451446271450100346650ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class AbstractBenchmarkStateTearDownTest { @State(Scope.Benchmark) public static class MyState extends AbstractTearDownBase {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchSetupTest.java000066400000000000000000000054461446271450100334630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) @State(Scope.Group) public class AbstractGroupBenchSetupTest extends AbstractSetupBase { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } AbstractGroupBenchTearDownTest.java000066400000000000000000000054551446271450100340270ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) @State(Scope.Group) public class AbstractGroupBenchTearDownTest extends AbstractTearDownBase { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateSetupTest.java000066400000000000000000000055331446271450100335210ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class AbstractGroupStateSetupTest { @State(Scope.Group) public static class MyState extends AbstractSetupBase {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } AbstractGroupStateTearDownTest.java000066400000000000000000000055421446271450100340650ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class AbstractGroupStateTearDownTest { @State(Scope.Group) public static class MyState extends AbstractTearDownBase {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractSetupBase.java000066400000000000000000000026321446271450100314330ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.openjdk.jmh.annotations.Setup; public abstract class AbstractSetupBase { @Setup public void setup() { Assert.fail(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractTearDownBase.java000066400000000000000000000026461446271450100320630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.openjdk.jmh.annotations.TearDown; public abstract class AbstractTearDownBase { @TearDown public void tearDown() { Assert.fail(); } } AbstractThreadBenchSetupTest.java000066400000000000000000000053441446271450100335140ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) @State(Scope.Thread) public class AbstractThreadBenchSetupTest extends AbstractSetupBase { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } AbstractThreadBenchTearDownTest.java000066400000000000000000000053521446271450100341360ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) @State(Scope.Thread) public class AbstractThreadBenchTearDownTest extends AbstractTearDownBase { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } AbstractThreadStateSetupTest.java000066400000000000000000000054311446271450100335520ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class AbstractThreadStateSetupTest { @State(Scope.Thread) public static class MyState extends AbstractSetupBase {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } AbstractThreadStateTearDownTest.java000066400000000000000000000054371446271450100342030ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class AbstractThreadStateTearDownTest { @State(Scope.Thread) public static class MyState extends AbstractTearDownBase {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } InheritBenchmarkBenchSetupTest.java000066400000000000000000000052121446271450100340300ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritBenchmarkBenchSetupTest extends InheritableBenchmarkSetupState { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } InheritBenchmarkBenchTearDownTest.java000066400000000000000000000052201446271450100344520ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritBenchmarkBenchTearDownTest extends InheritableBenchmarkTearDownState { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } InheritBenchmarkStateSetupTest.java000066400000000000000000000052731446271450100341000ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritBenchmarkStateSetupTest { public static class MyState extends InheritableBenchmarkSetupState {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } InheritBenchmarkStateTearDownTest.java000066400000000000000000000053011446271450100345130ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritBenchmarkStateTearDownTest { public static class MyState extends InheritableBenchmarkTearDownState {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchSetupTest.java000066400000000000000000000053061446271450100333150ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritGroupBenchSetupTest extends InheritableGroupSetupState { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } InheritGroupBenchTearDownTest.java000066400000000000000000000053141446271450100336600ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritGroupBenchTearDownTest extends InheritableGroupTearDownState { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateSetupTest.java000066400000000000000000000053701446271450100333570ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritGroupStateSetupTest { public static class MyState extends InheritableGroupSetupState {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } InheritGroupStateTearDownTest.java000066400000000000000000000053751446271450100337300ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritGroupStateTearDownTest { public static class MyState extends InheritableGroupTearDownState {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadBenchSetupTest.java000066400000000000000000000052041446271450100334250ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritThreadBenchSetupTest extends InheritableThreadSetupState { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } InheritThreadBenchTearDownTest.java000066400000000000000000000052121446271450100337700ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritThreadBenchTearDownTest extends InheritableThreadTearDownState { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadStateSetupTest.java000066400000000000000000000052651446271450100334750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritThreadStateSetupTest { public static class MyState extends InheritableThreadSetupState {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } InheritThreadStateTearDownTest.java000066400000000000000000000052731446271450100340400ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ @BenchmarkMode(Mode.All) public class InheritThreadStateTearDownTest { public static class MyState extends InheritableThreadTearDownState {} @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.fail("Should have failed"); } catch (RunnerException e) { // expected } } } InheritableBenchmarkSetupState.java000066400000000000000000000030121446271450100340510ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; @State(Scope.Benchmark) public class InheritableBenchmarkSetupState { @Setup public void setup() { Assert.fail(); } } InheritableBenchmarkTearDownState.java000066400000000000000000000030261446271450100345010ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; @State(Scope.Benchmark) public class InheritableBenchmarkTearDownState { @TearDown public void tearDown() { Assert.fail(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritableGroupSetupState.java000066400000000000000000000030021446271450100333310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; @State(Scope.Group) public class InheritableGroupSetupState { @Setup public void setup() { Assert.fail(); } } InheritableGroupTearDownState.java000066400000000000000000000030161446271450100337020ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; @State(Scope.Group) public class InheritableGroupTearDownState { @TearDown public void tearDown() { Assert.fail(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritableThreadSetupState.java000066400000000000000000000030041446271450100334460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; @State(Scope.Thread) public class InheritableThreadSetupState { @Setup public void setup() { Assert.fail(); } } InheritableThreadTearDownState.java000066400000000000000000000030201446271450100340100ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fails.inherit; import org.junit.Assert; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; @State(Scope.Thread) public class InheritableThreadTearDownState { @TearDown public void tearDown() { Assert.fail(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/footprint/000077500000000000000000000000001446271450100244725ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/footprint/ForkedFootprintTest.java000066400000000000000000000046771446271450100313320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.footprint; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; public class ForkedFootprintTest { @Benchmark public void bench() { // deliberately left empty: harness should work a lot } @Test public void testBenchmark() throws RunnerException { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .shouldFailOnError(true) .measurementIterations(mode == Mode.SingleShotTime ? 500_000 : 1_000) .measurementTime(TimeValue.milliseconds(5)) .warmupIterations(0) .forks(1) .jvmArgs("-Xmx16m", "-Xms16m") .build(); new Runner(opts).runSingle(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/000077500000000000000000000000001446271450100234075ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/AnnotatedClassForkedTest.java000066400000000000000000000055151446271450100311560ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ @BenchmarkMode(Mode.All) @Fork public class AnnotatedClassForkedTest { private static volatile boolean test1executed; private static volatile boolean test2executed; @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); test1executed = true; Assert.assertFalse(test2executed); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test2() { Fixtures.work(); test2executed = true; Assert.assertFalse(test1executed); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/AnnotatedForked1_Test.java000066400000000000000000000061461446271450100304110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ @BenchmarkMode(Mode.All) public class AnnotatedForked1_Test { private static volatile boolean test1executed; private static volatile boolean test2executed; @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); test1executed = true; Assert.assertFalse(test2executed); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(2) public void test2() { Fixtures.work(); test2executed = true; Assert.assertFalse(test1executed); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } @Test public void invokeF_API() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/AnnotatedForked2_Test.java000066400000000000000000000055311446271450100304070ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ @BenchmarkMode(Mode.All) public class AnnotatedForked2_Test { private static volatile boolean test1executed; private static volatile boolean test2executed; @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test1() { Fixtures.work(); test1executed = true; Assert.assertFalse(test2executed); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(value = 2, warmups = 1) public void test2() { Fixtures.work(); test2executed = true; Assert.assertFalse(test1executed); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkMergeTest.java000066400000000000000000000046701446271450100270020ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Fork(5) public class ForkMergeTest { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgsAppend = {"-Dbar"}) public void test() { Fixtures.work(); Assert.assertNotNull(System.getProperty("bar")); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); RunResult result = new Runner(opt).runSingle(); Assert.assertEquals(5, result.getAggregatedResult().getPrimaryResult().getSampleCount()); } }jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkSeparateClasspathJARTest.java000066400000000000000000000055431446271450100317070ustar00rootroot00000000000000/* * Copyright (c) 2017, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Fork(1) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public class ForkSeparateClasspathJARTest { @Benchmark public void test() { Fixtures.work(); } @Test public void withEnabled() throws RunnerException { System.setProperty("jmh.separateClasspathJAR", "true"); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); RunResult result = new Runner(opt).runSingle(); Assert.assertEquals(1, result.getAggregatedResult().getPrimaryResult().getSampleCount()); } @Test public void withDisabled() throws RunnerException { System.setProperty("jmh.separateClasspathJAR", "false"); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); RunResult result = new Runner(opt).runSingle(); Assert.assertEquals(1, result.getAggregatedResult().getPrimaryResult().getSampleCount()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkedJvmAppendPrependArgs1_Test.java000066400000000000000000000074701446271450100325140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) public class ForkedJvmAppendPrependArgs1_Test { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgs = "-Dmiddle", jvmArgsAppend = "-Dappended", jvmArgsPrepend = "-Dprepended") public void test1() { Fixtures.work(); Assert.assertNotNull(System.getProperty("middle")); Assert.assertNotNull(System.getProperty("appended")); Assert.assertNotNull(System.getProperty("prepended")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgsAppend = "-Dappended", jvmArgsPrepend = "-Dprepended") public void test2() { Fixtures.work(); Assert.assertNull(System.getProperty("middle")); Assert.assertNotNull(System.getProperty("appended")); Assert.assertNotNull(System.getProperty("prepended")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgsPrepend = "-Dprepended") public void test3() { Fixtures.work(); Assert.assertNull(System.getProperty("middle")); Assert.assertNull(System.getProperty("appended")); Assert.assertNotNull(System.getProperty("prepended")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgsAppend = "-Dappended") public void test4() { Fixtures.work(); Assert.assertNull(System.getProperty("middle")); Assert.assertNotNull(System.getProperty("appended")); Assert.assertNull(System.getProperty("prepended")); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkedJvmAppendPrependArgs2_Test.java000066400000000000000000000115411446271450100325070ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) @Fork(jvmArgsAppend = "-DappendedUp", jvmArgsPrepend = "-DprependedUp") public class ForkedJvmAppendPrependArgs2_Test { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgs = "-Dmiddle", jvmArgsAppend = "-Dappended", jvmArgsPrepend = "-Dprepended") public void test1() { Fixtures.work(); Assert.assertNotNull(System.getProperty("middle")); Assert.assertNotNull(System.getProperty("appended")); Assert.assertNotNull(System.getProperty("prepended")); Assert.assertNull(System.getProperty("appendedUp")); Assert.assertNull(System.getProperty("prependedUp")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgsAppend = "-Dappended", jvmArgsPrepend = "-Dprepended") public void test2() { Fixtures.work(); Assert.assertNull(System.getProperty("middle")); Assert.assertNotNull(System.getProperty("appended")); Assert.assertNotNull(System.getProperty("prepended")); Assert.assertNull(System.getProperty("appendedUp")); Assert.assertNull(System.getProperty("prependedUp")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgsPrepend = "-Dprepended") public void test3() { Fixtures.work(); Assert.assertNull(System.getProperty("middle")); Assert.assertNull(System.getProperty("appended")); Assert.assertNotNull(System.getProperty("prepended")); Assert.assertNotNull(System.getProperty("appendedUp")); Assert.assertNull(System.getProperty("prependedUp")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgsAppend = "-Dappended") public void test4() { Fixtures.work(); Assert.assertNull(System.getProperty("middle")); Assert.assertNotNull(System.getProperty("appended")); Assert.assertNull(System.getProperty("prepended")); Assert.assertNull(System.getProperty("appendedUp")); Assert.assertNotNull(System.getProperty("prependedUp")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork public void test5() { Fixtures.work(); Assert.assertNull(System.getProperty("middle")); Assert.assertNull(System.getProperty("appended")); Assert.assertNull(System.getProperty("prepended")); Assert.assertNotNull(System.getProperty("appendedUp")); Assert.assertNotNull(System.getProperty("prependedUp")); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkedJvmArgs1_Test.java000066400000000000000000000054321446271450100300420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) public class ForkedJvmArgs1_Test { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgs = "-Dtest1") public void test1() { Fixtures.work(); Assert.assertNotNull(System.getProperty("test1")); Assert.assertNull(System.getProperty("test2")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgs = "-Dtest2") public void test2() { Fixtures.work(); Assert.assertNull(System.getProperty("test1")); Assert.assertNotNull(System.getProperty("test2")); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkedJvmArgs2_Test.java000066400000000000000000000072101446271450100300370ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) @Fork(jvmArgs = "-DtestUpper") public class ForkedJvmArgs2_Test { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgs = "-Dtest1") public void test1() { Fixtures.work(); Assert.assertNotNull(System.getProperty("test1")); Assert.assertNull(System.getProperty("test2")); Assert.assertNull(System.getProperty("testUpper")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgs = "-Dtest2") public void test2() { Fixtures.work(); Assert.assertNull(System.getProperty("test1")); Assert.assertNotNull(System.getProperty("test2")); Assert.assertNull(System.getProperty("testUpper")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork public void testUpper() { Fixtures.work(); Assert.assertNull(System.getProperty("test1")); Assert.assertNull(System.getProperty("test2")); Assert.assertNotNull(System.getProperty("testUpper")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void testNone() { Fixtures.work(); Assert.assertNull(System.getProperty("test1")); Assert.assertNull(System.getProperty("test2")); Assert.assertNotNull(System.getProperty("testUpper")); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkedJvmArgs3_Test.java000066400000000000000000000057431446271450100300510ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * tests multiply spaces in jvmArgs annotations. */ @BenchmarkMode(Mode.All) public class ForkedJvmArgs3_Test { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgs = {"-Dtest1", "-Dtest3"}) public void test1() { Fixtures.work(); Assert.assertNotNull(System.getProperty("test1")); Assert.assertNull(System.getProperty("test2")); Assert.assertNotNull(System.getProperty("test3")); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(jvmArgs = {"-Dtest2", "-Dtest3"}) public void test2() { Fixtures.work(); Assert.assertNull(System.getProperty("test1")); Assert.assertNotNull(System.getProperty("test2")); Assert.assertNotNull(System.getProperty("test3")); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkedTest.java000066400000000000000000000066171446271450100263360ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ @BenchmarkMode(Mode.All) public class ForkedTest { private static volatile boolean test1executed; private static volatile boolean test2executed; @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); test1executed = true; Assert.assertFalse(test2executed); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test2() { Fixtures.work(); test2executed = true; Assert.assertFalse(test1executed); } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); } @Test public void invokeAPI_1() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); } @Test public void invokeAPI_WF() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .warmupForks(2) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/000077500000000000000000000000001446271450100252265ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_D_D_Test.java000066400000000000000000000047221446271450100322040ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_D_D_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_D_F0_Test.java000066400000000000000000000047541446271450100322730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_D_F0_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(true, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_D_F1_Test.java000066400000000000000000000047551446271450100322750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_D_F1_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_D_F_Test.java000066400000000000000000000047541446271450100322130ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_D_F_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F0_D_Test.java000066400000000000000000000050101446271450100322550ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F0_D_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork(0) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.assertEquals(true, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F0_F0_Test.java000066400000000000000000000050441446271450100323460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F0_F0_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork(0) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(true, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F0_F1_Test.java000066400000000000000000000050441446271450100323470ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F0_F1_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork(0) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F0_F_Test.java000066400000000000000000000050431446271450100322650ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F0_F_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork(0) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F1_D_Test.java000066400000000000000000000050111446271450100322570ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F1_D_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork(1) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F1_F0_Test.java000066400000000000000000000050431446271450100323460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F1_F0_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork(1) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(true, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F1_F1_Test.java000066400000000000000000000050441446271450100323500ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F1_F1_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork(1) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F1_F_Test.java000066400000000000000000000050431446271450100322660ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F1_F_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork(1) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F_D_Test.java000066400000000000000000000050051446271450100322010ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F_D_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F_F0_Test.java000066400000000000000000000050371446271450100322700ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F_F0_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(true, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F_F1_Test.java000066400000000000000000000050411446271450100322640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F_F1_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/override/ForkOverride_F_F_Test.java000066400000000000000000000050371446271450100322100ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.fork.override; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Tests if harness had indeed executed different tests in different JVMs. */ public class ForkOverride_F_F_Test { private static volatile boolean sameVM; @Benchmark @BenchmarkMode(Mode.All) @Fork @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test1() { Fixtures.work(); sameVM = true; } @Test public void invokeAPI() throws RunnerException { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(1) .build(); new Runner(opt).run(); Assert.assertEquals(false, sameVM); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/000077500000000000000000000000001446271450100247515ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/BenchmarkParamsTest.java000066400000000000000000000054121446271450100315140ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.infraparams; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.CommandLineOptionException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Collection; import java.util.Collections; import java.util.IdentityHashMap; @State(Scope.Thread) public class BenchmarkParamsTest { Collection set; @Setup(Level.Iteration) public void setup() { set = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<>())); } @TearDown(Level.Iteration) public void verify() { Assert.assertEquals(1, set.size()); } @Benchmark @Threads(4) public void test(BenchmarkParams params) { set.add(params); Fixtures.work(); } @Test public void test() throws RunnerException, CommandLineOptionException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .warmupIterations(5) .warmupTime(TimeValue.seconds(1)) .measurementIterations(5) .measurementTime(TimeValue.seconds(1)) .forks(1) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/IterationParamsTest.java000066400000000000000000000053771446271450100315720ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.infraparams; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.CommandLineOptionException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; @State(Scope.Benchmark) public class IterationParamsTest { Set set; @Setup(Level.Iteration) public void setup() { set = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<>())); } @TearDown(Level.Iteration) public void verify() { Assert.assertEquals(1, set.size()); } @Benchmark @Threads(4) public void test(IterationParams params) { set.add(params); Fixtures.work(); } @Test public void test() throws RunnerException, CommandLineOptionException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .warmupIterations(5) .warmupTime(TimeValue.seconds(1)) .measurementIterations(5) .measurementTime(TimeValue.seconds(1)) .forks(1) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/ThreadParamsTest.java000066400000000000000000000051221446271450100310270ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.infraparams; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.ThreadParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.*; import java.util.Collection; import java.util.Collections; import java.util.IdentityHashMap; @State(Scope.Benchmark) public class ThreadParamsTest { Collection set; @Setup(Level.Iteration) public void setup() { set = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<>())); } @TearDown(Level.Iteration) public void verify() { Assert.assertEquals(4, set.size()); } @Benchmark @Threads(4) public void test(ThreadParams params) { set.add(params); Fixtures.work(); } @Test public void test() throws RunnerException, CommandLineOptionException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .warmupIterations(5) .warmupTime(TimeValue.seconds(1)) .measurementIterations(5) .measurementTime(TimeValue.seconds(1)) .forks(1) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/000077500000000000000000000000001446271450100246235ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkBenchOrderTest.java000066400000000000000000000110601446271450100321520ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.interorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Benchmark) public class BenchmarkBenchOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private volatile int tickSetInstance; private volatile int tickSetIteration; private volatile int tickSetInvocation; private volatile int tickTearInstance; private volatile int tickTearIteration; private volatile int tickTearInvocation; private volatile int tickRun; @Setup(Level.Trial) public void setupInstance() { tickSetInstance = TICKER.incrementAndGet(); } @Setup(Level.Iteration) public void setupIteration() { tickSetIteration = TICKER.incrementAndGet(); } @Setup(Level.Invocation) public void setupInvocation() { tickSetInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDownInvocation() { tickTearInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownIteration() { tickTearIteration = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { tickTearInstance = TICKER.incrementAndGet(); Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration); Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation); Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun); Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation); Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration); Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(1) public void test() { tickRun = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkStateOrderTest.java000066400000000000000000000114021446271450100322130ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.interorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class BenchmarkStateOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); @State(Scope.Benchmark) public static class MyState { private volatile int tickSetInstance; private volatile int tickSetIteration; private volatile int tickSetInvocation; private volatile int tickTearInstance; private volatile int tickTearIteration; private volatile int tickTearInvocation; private volatile int tickRun; @Setup(Level.Trial) public void setupInstance() { tickSetInstance = TICKER.incrementAndGet(); } @Setup(Level.Iteration) public void setupIteration() { tickSetIteration = TICKER.incrementAndGet(); } @Setup(Level.Invocation) public void setupInvocation() { tickSetInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDownInvocation() { tickTearInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownIteration() { tickTearIteration = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { tickTearInstance = TICKER.incrementAndGet(); Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration); Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation); Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun); Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation); Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration); Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(1) public void test(MyState state) { state.tickRun = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupBenchOrderTest.java000066400000000000000000000110461446271450100313600ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.interorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Group) public class GroupBenchOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private volatile int tickSetInstance; private volatile int tickSetIteration; private volatile int tickSetInvocation; private volatile int tickTearInstance; private volatile int tickTearIteration; private volatile int tickTearInvocation; private volatile int tickRun; @Setup(Level.Trial) public void setupInstance() { tickSetInstance = TICKER.incrementAndGet(); } @Setup(Level.Iteration) public void setupIteration() { tickSetIteration = TICKER.incrementAndGet(); } @Setup(Level.Invocation) public void setupInvocation() { tickSetInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDownInvocation() { tickTearInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownIteration() { tickTearIteration = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { tickTearInstance = TICKER.incrementAndGet(); Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration); Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation); Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun); Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation); Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration); Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") public void test() { tickRun = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupStateOrderTest.java000066400000000000000000000113711446271450100314220ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.interorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class GroupStateOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); @State(Scope.Group) public static class MyState { private volatile int tickSetInstance; private volatile int tickSetIteration; private volatile int tickSetInvocation; private volatile int tickTearInstance; private volatile int tickTearIteration; private volatile int tickTearInvocation; private volatile int tickRun; @Setup(Level.Trial) public void setupInstance() { tickSetInstance = TICKER.incrementAndGet(); } @Setup(Level.Iteration) public void setupIteration() { tickSetIteration = TICKER.incrementAndGet(); } @Setup(Level.Invocation) public void setupInvocation() { tickSetInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDownInvocation() { tickTearInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownIteration() { tickTearIteration = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { tickTearInstance = TICKER.incrementAndGet(); Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration); Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation); Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun); Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation); Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration); Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") public void test(MyState state) { state.tickRun = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadBenchOrderTest.java000066400000000000000000000110521446271450100314700ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.interorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Thread) public class ThreadBenchOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); private volatile int tickSetInstance; private volatile int tickSetIteration; private volatile int tickSetInvocation; private volatile int tickTearInstance; private volatile int tickTearIteration; private volatile int tickTearInvocation; private volatile int tickRun; @Setup(Level.Trial) public void setupInstance() { tickSetInstance = TICKER.incrementAndGet(); } @Setup(Level.Iteration) public void setupIteration() { tickSetIteration = TICKER.incrementAndGet(); } @Setup(Level.Invocation) public void setupInvocation() { tickSetInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDownInvocation() { tickTearInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownIteration() { tickTearIteration = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { tickTearInstance = TICKER.incrementAndGet(); Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration); Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation); Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun); Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation); Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration); Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(1) public void test() { tickRun = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadStateOrderTest.java000066400000000000000000000113741446271450100315400ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.interorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class ThreadStateOrderTest { public static final AtomicInteger TICKER = new AtomicInteger(); @State(Scope.Thread) public static class MyState { private volatile int tickSetInstance; private volatile int tickSetIteration; private volatile int tickSetInvocation; private volatile int tickTearInstance; private volatile int tickTearIteration; private volatile int tickTearInvocation; private volatile int tickRun; @Setup(Level.Trial) public void setupInstance() { tickSetInstance = TICKER.incrementAndGet(); } @Setup(Level.Iteration) public void setupIteration() { tickSetIteration = TICKER.incrementAndGet(); } @Setup(Level.Invocation) public void setupInvocation() { tickSetInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDownInvocation() { tickTearInvocation = TICKER.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDownIteration() { tickTearIteration = TICKER.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownInstance() { tickTearInstance = TICKER.incrementAndGet(); Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration); Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation); Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun); Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation); Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration); Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(1) public void test(MyState state) { state.tickRun = TICKER.incrementAndGet(); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/000077500000000000000000000000001446271450100246655ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/InterruptibleInterruptTest.java000066400000000000000000000047041446271450100331420ustar00rootroot00000000000000/* * Copyright (c) 2021, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.interrupts; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.concurrent.TimeUnit; @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public class InterruptibleInterruptTest { @Benchmark public void test() { try { Thread.sleep(5_000); } catch (InterruptedException e) { // Harness delivered, just exit. } } @Test public void invokeAPI() throws RunnerException { for (Mode m : Mode.values()) { if (m != Mode.All) continue; Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .mode(m) .timeout(TimeValue.seconds(1)) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/NonInterruptibleInterruptTest.java000066400000000000000000000050651446271450100336160ustar00rootroot00000000000000/* * Copyright (c) 2021, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.interrupts; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.concurrent.TimeUnit; @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public class NonInterruptibleInterruptTest { @Benchmark public void test() { // This method deliberately does not check interrupt status. long start = System.currentTimeMillis(); long end = start + 5_000; while (System.currentTimeMillis() < end) { Blackhole.consumeCPU(10_000); } } @Test public void invokeAPI() throws RunnerException { for (Mode m : Mode.values()) { if (m != Mode.All) continue; Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .mode(m) .timeout(TimeValue.seconds(1)) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/000077500000000000000000000000001446271450100246175ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/BenchmarkBenchSetupOrderTest.java000066400000000000000000000115431446271450100331750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ @State(Scope.Benchmark) public class BenchmarkBenchSetupOrderTest { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @Setup(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } BenchmarkBenchTearDownOrderTest.java000066400000000000000000000115401446271450100335360ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ @State(Scope.Benchmark) public class BenchmarkBenchTearDownOrderTest { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @TearDown(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/BenchmarkStateSetupOrderTest.java000066400000000000000000000121421446271450100332320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ public class BenchmarkStateSetupOrderTest { @State(Scope.Benchmark) public static class MyState { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @Setup(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } BenchmarkStateTearDownOrderTest.java000066400000000000000000000121401446271450100335740ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ public class BenchmarkStateTearDownOrderTest { @State(Scope.Benchmark) public static class MyState { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @TearDown(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupBenchSetupOrderTest.java000066400000000000000000000116401446271450100323750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ @State(Scope.Group) public class GroupBenchSetupOrderTest { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @Setup(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(2) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupBenchTearDownOrderTest.java000066400000000000000000000116351446271450100330240ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ @State(Scope.Group) public class GroupBenchTearDownOrderTest { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @TearDown(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(2) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupStateSetupOrderTest.java000066400000000000000000000122251446271450100324360ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ public class GroupStateSetupOrderTest { @State(Scope.Group) public static class MyState { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @Setup(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupStateTearDownOrderTest.java000066400000000000000000000122221446271450100330560ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ public class GroupStateTearDownOrderTest { @State(Scope.Group) public static class MyState { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @TearDown(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/ThreadBenchSetupOrderTest.java000066400000000000000000000115361446271450100325140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ @State(Scope.Thread) public class ThreadBenchSetupOrderTest { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @Setup(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/ThreadBenchTearDownOrderTest.java000066400000000000000000000115331446271450100331340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ @State(Scope.Thread) public class ThreadBenchTearDownOrderTest { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @TearDown(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/ThreadStateSetupOrderTest.java000066400000000000000000000121351446271450100325510ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ public class ThreadStateSetupOrderTest { @State(Scope.Thread) public static class MyState { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @Setup(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @Setup(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @Setup(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @Setup(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/ThreadStateTearDownOrderTest.java000066400000000000000000000121321446271450100331710ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.intraorder; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup (instance) methods in lexicographical order. */ public class ThreadStateTearDownOrderTest { @State(Scope.Thread) public static class MyState { private final AtomicInteger seq = new AtomicInteger(); private int run1, run2, run3, runD; private int iter1, iter2, iter3, iterD; private int invoc1, invoc2, invoc3, invocD; @TearDown(Level.Trial) public void run1() { run1 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run3() { run3 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run2() { run2 = seq.incrementAndGet(); } @TearDown(Level.Trial) public void run() { runD = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration1() { iter1 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration3() { iter3 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration2() { iter2 = seq.incrementAndGet(); } @TearDown(Level.Iteration) public void iteration() { iterD = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation1() { invoc1 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation3() { invoc3 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation2() { invoc2 = seq.incrementAndGet(); } @TearDown(Level.Invocation) public void invocation() { invocD = seq.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test(MyState state) { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/jvmoption/000077500000000000000000000000001446271450100244735ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/jvmoption/JvmOptionTest.java000066400000000000000000000047741446271450100301370ustar00rootroot00000000000000/* * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.jvmoption; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.util.Utils; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Thread) public class JvmOptionTest { @Param("") public String x; @Benchmark public void test() { Fixtures.work(); } @Test public void test_api() throws RunnerException { Path currentJvm = Paths.get(Utils.getCurrentJvm()); // Construct an alternative path to the JVM to exercise PrintPropertiesMain Path alternativePathToJvm = currentJvm.getParent().resolve(".").resolve(currentJvm.getFileName()); Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .jvm(alternativePathToJvm.toString()) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/000077500000000000000000000000001446271450100246115ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/Parameters.java000066400000000000000000000041211446271450100275550ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters; import org.junit.Assert; import org.openjdk.jmh.runner.BenchmarkList; import org.openjdk.jmh.runner.BenchmarkListEntry; import org.openjdk.jmh.runner.format.OutputFormatFactory; import org.openjdk.jmh.runner.options.VerboseMode; import java.util.Arrays; import java.util.Collections; import java.util.Set; public class Parameters { public static BenchmarkListEntry get(Class klass) { BenchmarkList list = BenchmarkList.fromFile("target/test-classes" + BenchmarkList.BENCHMARK_LIST); Set set = list.find(OutputFormatFactory.createFormatInstance(System.out, VerboseMode.EXTRA), Collections.singletonList(klass.getName().replaceAll("\\$", ".")), Collections.emptyList()); Assert.assertEquals("The single benchmark exists", 1, set.size()); return set.iterator().next(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/fork/000077500000000000000000000000001446271450100255525ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/fork/BenchForkTest.java000066400000000000000000000032411446271450100311160ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.it.parameters.Parameters; @Fork(10) public class BenchForkTest { @Benchmark public void bench() { // do nothing } @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getForks().get()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/fork/BenchMethodForkTest.java000066400000000000000000000032651446271450100322650ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.it.parameters.Parameters; @Fork(20) public class BenchMethodForkTest { @Fork(10) @Benchmark public void bench() { // do nothing } @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getForks().get()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/fork/MethodForkTest.java000066400000000000000000000032461446271450100313240ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.fork; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.it.parameters.Parameters; public class MethodForkTest { @Fork(10) @Benchmark public void bench() { // do nothing } @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getForks().get()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/000077500000000000000000000000001446271450100262435ustar00rootroot00000000000000BenchmarkGroupThreadsTest.java000066400000000000000000000035121446271450100341120ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.it.parameters.Parameters; @Threads(10) public class BenchmarkGroupThreadsTest { @Group("a") @Benchmark public void bench1() { // do nothing } @Group("a") @Benchmark public void bench2() { // do nothing } @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getThreads().get()); } } BenchmarkMethodThreadsTest.java000066400000000000000000000033121446271450100342340ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.it.parameters.Parameters; @Threads(20) public class BenchmarkMethodThreadsTest { @Threads(10) @Benchmark public void bench() { // do nothing } @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getThreads().get()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/BenchmarkThreadsTest.java000066400000000000000000000032631446271450100331570ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.it.parameters.Parameters; @Threads(10) public class BenchmarkThreadsTest { @Benchmark public void bench() { // do nothing } @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getThreads().get()); } } InheritedBenchMethodThreadsTest.java000066400000000000000000000035621446271450100352240ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.it.parameters.Parameters; public class InheritedBenchMethodThreadsTest { @Threads(20) public static abstract class AbstractBenchmark { @Threads(10) @Benchmark public void bench() { // do nothing } } public static class ConcreteBenchmark extends AbstractBenchmark {} @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(ConcreteBenchmark.class).getThreads().get()); } } InheritedBenchSubclassThreadsTest.java000066400000000000000000000035371446271450100355650ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.it.parameters.Parameters; public class InheritedBenchSubclassThreadsTest { public static abstract class AbstractBenchmark { @Benchmark public void bench() { // do nothing } } @Threads(10) public static class ConcreteBenchmark extends AbstractBenchmark {} @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(ConcreteBenchmark.class).getThreads().get()); } } InheritedBenchThreadsTest.java000066400000000000000000000035271446271450100340640ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.it.parameters.Parameters; public class InheritedBenchThreadsTest { @Threads(10) public static abstract class AbstractBenchmark { @Benchmark public void bench() { // do nothing } } public static class ConcreteBenchmark extends AbstractBenchmark {} @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(ConcreteBenchmark.class).getThreads().get()); } } InheritedMethodThreadsTest.java000066400000000000000000000035341446271450100342630ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.it.parameters.Parameters; public class InheritedMethodThreadsTest { public static abstract class AbstractBenchmark { @Threads(10) @Benchmark public void bench() { // do nothing } } public static class ConcreteBenchmark extends AbstractBenchmark {} @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(ConcreteBenchmark.class).getThreads().get()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/MethodThreadsTest.java000066400000000000000000000032641446271450100325060ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.parameters.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.it.parameters.Parameters; public class MethodThreadsTest { @Threads(10) @Benchmark public void bench() { // do nothing } @Test public void test() { Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getThreads().get()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/000077500000000000000000000000001446271450100237315ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/BenchmarkBenchParamSequenceTest.java000066400000000000000000000064161446271450100327470ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) @State(Scope.Benchmark) public class BenchmarkBenchParamSequenceTest { @Param({"1", "2", "3"}) public int x; @Param({"a", "b", "c"}) public String y; @Benchmark public void test() { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"}); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/BenchmarkStateParamSequenceTest.java000066400000000000000000000065231446271450100330070ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) public class BenchmarkStateParamSequenceTest { @State(Scope.Benchmark) public static class MyState { @Param({"1", "2", "3"}) public int x; @Param({"a", "b", "c"}) public String y; } @Benchmark public void test(MyState s) { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"}); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/CollidingParamsTest.java000066400000000000000000000052171446271450100305110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; public class CollidingParamsTest { @State(Scope.Benchmark) public static class Benchmark1 { @Param("1") private int x; @Benchmark public void test() { } } @State(Scope.Benchmark) public static class Benchmark2 { @Param("2") private int x; @Benchmark public void test() { } } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .warmupIterations(1) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(100)) .forks(1) .shouldFailOnError(true) .param("x", "2", "3") .build(); Assert.assertEquals(4, new Runner(opts).run().size()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyLeadingStringParamTest.java000066400000000000000000000063411446271450100321720ustar00rootroot00000000000000/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Thread) public class EmptyLeadingStringParamTest { @Param({"", "val"}) public String x; @Benchmark public void test() { Fixtures.work(); } @Test public void test_ann() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Collection res = new Runner(opts).run(); Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } Assert.assertEquals(2, actualP.size()); Assert.assertTrue(actualP.contains("val")); Assert.assertTrue(actualP.contains("")); } @Test public void test_api() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "", "val") .build(); Collection res = new Runner(opts).run(); Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } Assert.assertEquals(2, actualP.size()); Assert.assertTrue(actualP.contains("val")); Assert.assertTrue(actualP.contains("")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyMiddleStringParamTest.java000066400000000000000000000065361446271450100320330ustar00rootroot00000000000000/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Thread) public class EmptyMiddleStringParamTest { @Param({"val1", "", "val2"}) public String x; @Benchmark public void test() { Fixtures.work(); } @Test public void test_ann() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Collection res = new Runner(opts).run(); Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } Assert.assertEquals(3, actualP.size()); Assert.assertTrue(actualP.contains("val1")); Assert.assertTrue(actualP.contains("val2")); Assert.assertTrue(actualP.contains("")); } @Test public void test_api() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "val1", "", "val2") .build(); Collection res = new Runner(opts).run(); Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } Assert.assertEquals(3, actualP.size()); Assert.assertTrue(actualP.contains("val1")); Assert.assertTrue(actualP.contains("val2")); Assert.assertTrue(actualP.contains("")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyStringParamTest.java000066400000000000000000000046611446271450100307110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Thread) public class EmptyStringParamTest { @Param("") public String x; @Benchmark public void test() { Fixtures.work(); } @Test public void test_ann() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } @Test public void test_api() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "") .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyTrailingStringParamTest.java000066400000000000000000000063421446271450100324010ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Thread) public class EmptyTrailingStringParamTest { @Param({"val", ""}) public String x; @Benchmark public void test() { Fixtures.work(); } @Test public void test_ann() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Collection res = new Runner(opts).run(); Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } Assert.assertEquals(2, actualP.size()); Assert.assertTrue(actualP.contains("val")); Assert.assertTrue(actualP.contains("")); } @Test public void test_api() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "val", "") .build(); Collection res = new Runner(opts).run(); Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } Assert.assertEquals(2, actualP.size()); Assert.assertTrue(actualP.contains("val")); Assert.assertTrue(actualP.contains("")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumBenchParamImplicitSequenceTest.java000066400000000000000000000066111446271450100334510ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Thread) public class EnumBenchParamImplicitSequenceTest { @Param({"VALUE_A", "VALUE_B", "VALUE_C"}) public SampleEnumA a; @Param public SampleEnumB b; @Benchmark public void test() { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Assert.assertEquals(3 * 3, new Runner(opts).run().size()); } @Test public void constrainedA() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("a", SampleEnumA.VALUE_A.name()) .build(); Assert.assertEquals(1 * 3, new Runner(opts).run().size()); } @Test public void constrainedB() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("b", SampleEnumB.VALUE_A.name()) .build(); Assert.assertEquals(1*3, new Runner(opts).run().size()); } public enum SampleEnumA { VALUE_A, VALUE_B, VALUE_C } public enum SampleEnumB { VALUE_A, VALUE_B, VALUE_C } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamSequenceTest.java000066400000000000000000000066371446271450100310260ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) @State(Scope.Thread) public class EnumParamSequenceTest { @Param({"VALUE_A", "VALUE_B", "VALUE_C"}) public SampleEnumA a; @Param({"VALUE_A", "VALUE_B", "VALUE_C"}) public SampleEnumB b; @Benchmark public void test() { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Assert.assertEquals(3 * 3, new Runner(opts).run().size()); } @Test public void constrainedA() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("a", SampleEnumA.VALUE_A.name()) .build(); Assert.assertEquals(1 * 3, new Runner(opts).run().size()); } @Test public void constrainedB() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("b", SampleEnumB.VALUE_A.name()) .build(); Assert.assertEquals(1*3, new Runner(opts).run().size()); } public enum SampleEnumA { VALUE_A, VALUE_B, VALUE_C } public enum SampleEnumB { VALUE_A, VALUE_B, VALUE_C } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamToStringOverridingTest.java000066400000000000000000000052331446271450100330470ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) @State(Scope.Thread) public class EnumParamToStringOverridingTest { @Param({"VALUE_A", "VALUE_B", "VALUE_C"}) public SampleEnumA a; @Benchmark public void test() { Fixtures.work(); } @Test public void normal() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Assert.assertEquals(3, new Runner(opts).run().size()); } public enum SampleEnumA { VALUE_A, VALUE_B, VALUE_C; @Override public String toString() { return name().toLowerCase(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumStateParamImplicitSequenceTest.java000066400000000000000000000067271446271450100335220ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) public class EnumStateParamImplicitSequenceTest { @State(Scope.Benchmark) public static class MyState { @Param({ "VALUE_A", "VALUE_B", "VALUE_C" }) public SampleEnumA a; @Param public SampleEnumB b; } @Benchmark public void test(MyState state) { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Assert.assertEquals(3 * 3, new Runner(opts).run().size()); } @Test public void constrainedA() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("a", SampleEnumA.VALUE_A.name()) .build(); Assert.assertEquals(1 * 3, new Runner(opts).run().size()); } @Test public void constrainedB() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("b", SampleEnumB.VALUE_A.name()) .build(); Assert.assertEquals(1*3, new Runner(opts).run().size()); } public enum SampleEnumA { VALUE_A, VALUE_B, VALUE_C } public enum SampleEnumB { VALUE_A, VALUE_B, VALUE_C } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EscapedParamsTest.java000066400000000000000000000050631446271450100301500ustar00rootroot00000000000000/* * Copyright (c) 2019, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class EscapedParamsTest { @Param("value") public String param_plain; @Param("value\n") public String param_n; @Param("value\r") public String param_r; @Param("value\r\n") public String param_rn; @Param("value\n\r") public String param_nr; @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); Assert.assertEquals("value", param_plain); Assert.assertEquals("value\n", param_n); Assert.assertEquals("value\r", param_r); Assert.assertEquals("value\r\n", param_rn); Assert.assertEquals("value\n\r", param_nr); } @Test public void vals() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/GroupBenchParamSequenceTest.java000066400000000000000000000066331446271450100321520ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) @State(Scope.Group) public class GroupBenchParamSequenceTest { @Param({"1", "2", "3"}) public int x; @Param({"a", "b", "c"}) public String y; @Benchmark @Group("s") public void test1() { Fixtures.work(); } @Benchmark @Group("s") public void test2() { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c" }); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/GroupStateParamSequenceTest.java000066400000000000000000000067501446271450100322130ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) public class GroupStateParamSequenceTest { @State(Scope.Group) public static class MyState { @Param({"1", "2", "3"}) public int x; @Param({"a", "b", "c"}) public String y; } @Benchmark @Group("s") public void test1(MyState s) { Fixtures.work(); } @Benchmark @Group("s") public void test2(MyState s) { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"}); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/IsolatedParamSequenceTest.java000066400000000000000000000060761446271450100316630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) public class IsolatedParamSequenceTest { @State(Scope.Benchmark) public static class MyState { @Param({"1", "2", "3"}) public int x; } @Benchmark public void test1(MyState s) { Fixtures.work(); } @Benchmark public void test2() { Fixtures.work(); } @Test public void onlyTest1() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".*test1") .shouldFailOnError(true) .build(); Collection run = new Runner(opts).run(); Assert.assertEquals(3, run.size()); } @Test public void onlyTest2() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".*test2") .shouldFailOnError(true) .build(); Collection run = new Runner(opts).run(); Assert.assertEquals(1, run.size()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/MultipleParamTest.java000066400000000000000000000050431446271450100302120ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) @State(Scope.Thread) public class MultipleParamTest { @Param({"1", "2", "3"}) public int x; @Param({"4", "5", "6"}) public int y; @Param({"7", "8", "9"}) public int z; @Benchmark public void test() { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Assert.assertEquals(3*3*3, new Runner(opts).run().size()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/OverridingParamsTest.java000066400000000000000000000054561446271450100307220ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; public class OverridingParamsTest { @State(Scope.Benchmark) public static class Benchmark1 { @Param("1") private int x; @Benchmark public void test() { } } @State(Scope.Benchmark) public static class Benchmark2 extends Benchmark1 { @Param("2") private int x; @Benchmark public void overtest() { // check that all x parameters set to the same value Assert.assertEquals("this.x != super.x", this.x, super.x); } } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .warmupIterations(1) .warmupTime(TimeValue.milliseconds(100)) .measurementIterations(1) .measurementTime(TimeValue.milliseconds(100)) .forks(1) .shouldFailOnError(true) .param("x", "2", "3") .build(); Assert.assertEquals(6, new Runner(opts).run().size()); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/ParamDeclaredOrderTest.java000066400000000000000000000064501446271450100311210ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Warmup(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(0) @State(Scope.Thread) public class ParamDeclaredOrderTest { static int prevV; @Param({"1", "2", "4", "8", "16", "32", "64"}) public int v; @Setup(Level.Trial) public void setup() { Assert.assertTrue("Running in different VM", prevV != 0); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) public void test() { Fixtures.work(); Assert.assertTrue(v + " > " + prevV, v > prevV); } @TearDown(Level.Trial) public void tearDown() { prevV = v; } @Test public void invoke() throws RunnerException { prevV = -1; Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } @Test public void invokeOverride() throws RunnerException { prevV = -1; Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("128", "1024", "2048") .build(); new Runner(opt).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/QuotedParamsTest.java000066400000000000000000000051201446271450100300370ustar00rootroot00000000000000/* * Copyright (c) 2019, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class QuotedParamsTest { @Param("value") public String param_plain; @Param("[value]") public String param_square; @Param("{value}") public String param_curly; @Param("'value'") public String param_squote; @Param("\"value\"") public String param_dquote; @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); Assert.assertEquals("value", param_plain); Assert.assertEquals("[value]", param_square); Assert.assertEquals("{value}", param_curly); Assert.assertEquals("'value'", param_squote); Assert.assertEquals("\"value\"", param_dquote); } @Test public void vals() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java000066400000000000000000000036401446271450100260050ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.RunResult; import java.util.Collection; import java.util.HashSet; import java.util.Set; public class Shared { public static void compare(Collection res, int[] xs, String[] ys) { Set actualPairs = new HashSet<>(); for (RunResult r : res) { BenchmarkParams params = r.getParams(); actualPairs.add(params.getParam("x") + params.getParam("y")); } for (int x : xs) { for (String y : ys) { Assert.assertTrue(x + y + " is not found", actualPairs.contains(x + y)); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/StaticParamSanityTest.java000066400000000000000000000064171446271450100310440ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Thread) public class StaticParamSanityTest { @Param({"1", "2", "3"}) public static int x; @Param({"a", "b", "c"}) public static String y; @Benchmark public void test() { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"}); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/ThreadBenchParamSequenceTest.java000066400000000000000000000064101446271450100322560ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Thread) public class ThreadBenchParamSequenceTest { @Param({"1", "2", "3"}) public int x; @Param({"a", "b", "c"}) public String y; @Benchmark public void test() { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"}); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/ThreadStateParamSequenceTest.java000066400000000000000000000067031446271450100323240ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collection; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) public class ThreadStateParamSequenceTest { @State(Scope.Thread) public static class MyState { @Param({"1", "2", "3"}) public int x; @Param({"a", "b", "c"}) public String y; } @Benchmark public void test(MyState s) { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Collection params = new Runner(opts).run(); Shared.compare(params, new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"}); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/UTF8ParamsTest.java000066400000000000000000000045651446271450100273400ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Locale; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class UTF8ParamsTest { @Param("\uff11000") String value; @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); Assert.assertEquals("\uff11000", value); } @Test public void vals() throws RunnerException { Locale prev = Locale.getDefault(); Locale.setDefault(Locale.ROOT); try { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } finally { Locale.setDefault(prev); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/000077500000000000000000000000001446271450100252135ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedSetupDependencyTest.java000066400000000000000000000070551446271450100331670ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params.nested; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.it.params.Shared; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) @State(Scope.Benchmark) public class NestedSetupDependencyTest { @State(Scope.Benchmark) public static class S1 { @Param({"1", "2", "3"}) public int x; } @State(Scope.Thread) public static class S2 { @Param({"a", "b", "c"}) public String y; @Setup public void setup(S1 s) { } } @Benchmark public void bench(S2 s) { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[]{2, 3}, new String[]{"a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"}); } } NestedSubclassDependencyTest.java000066400000000000000000000067241446271450100335710ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params.nested; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.it.params.Shared; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) @State(Scope.Benchmark) public class NestedSubclassDependencyTest { @State(Scope.Benchmark) public static class S1 { @Param({"1", "2", "3"}) public int x; } @State(Scope.Thread) public static class S2 extends S1 { @Param({"a", "b", "c"}) public String y; } @Benchmark public void bench(S2 s) { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[]{2, 3}, new String[]{"a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"}); } } NestedSubclassImplicitDependencyTest.java000066400000000000000000000066671446271450100352720ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params.nested; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.it.params.Shared; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) @State(Scope.Benchmark) public class NestedSubclassImplicitDependencyTest { @Param({"1", "2", "3"}) public int x; @State(Scope.Thread) public static class S2 extends NestedSubclassImplicitDependencyTest { @Param({"a", "b", "c"}) public String y; } @Benchmark public void bench(S2 s) { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[]{2, 3}, new String[]{"a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"}); } } NestedTearDownDependencyTest.java000066400000000000000000000070711446271450100335310ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.params.nested; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.it.params.Shared; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) @Fork(1) @State(Scope.Benchmark) public class NestedTearDownDependencyTest { @State(Scope.Benchmark) public static class S1 { @Param({"1", "2", "3"}) public int x; } @State(Scope.Thread) public static class S2 { @Param({"a", "b", "c"}) public String y; @TearDown public void tearDown(S1 s) { } } @Benchmark public void bench(S2 s) { Fixtures.work(); } @Test public void full() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"}); } @Test public void constrainedX() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("x", "2", "3") .build(); Shared.compare(new Runner(opts).run(), new int[]{2, 3}, new String[]{"a", "b", "c"}); } @Test public void constrainedY() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .param("y", "b", "c") .build(); Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"}); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/000077500000000000000000000000001446271450100244535ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractAsmProfilerTest.java000066400000000000000000000050151446271450100320660ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.util.JDKVersion; import java.util.concurrent.TimeUnit; @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @State(Scope.Thread) public abstract class AbstractAsmProfilerTest { private static final int SIZE = 10_000; private byte[] src, dst; @Setup public void setup() { src = new byte[SIZE]; dst = new byte[SIZE]; } @Benchmark public void work() { // Call something that definitely results in calling a native stub. // This should work on environments where hsdis is not available. System.arraycopy(src, 0, dst, 0, SIZE); } public static boolean checkDisassembly(String out) { if (JDKVersion.parseMajor(System.getProperty("java.version")) >= 17) { // Should always print, since abstract assembler is available return out.contains("StubRoutines::"); } else { if (out.contains("StubRoutines::")) { // hsdis is enabled, good return true; } else { // hsdis is not enabled, okay return out.contains(""); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractHotspotProfilerTest.java000066400000000000000000000034371446271450100330140ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.openjdk.jmh.annotations.*; import java.util.concurrent.TimeUnit; @OutputTimeUnit(TimeUnit.NANOSECONDS) @Fork(1) // 0 to enable debugging @Warmup(iterations = 5) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @BenchmarkMode(Mode.AverageTime) public class AbstractHotspotProfilerTest { @Benchmark public Object alloc() { return new Object(); } boolean isHotspotVM() { String name = System.getProperty("java.vm.name"); return (name.contains("OpenJDK") || name.contains("HotSpot")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsExternalProfiler.java000066400000000000000000000046401446271450100331400ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.profile.ExternalProfiler; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.Result; import java.io.File; import java.util.Collection; import java.util.Collections; public class ChangeJVMOptsExternalProfiler implements ExternalProfiler { @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public Collection addJVMOptions(BenchmarkParams params) { return Collections.singletonList("-Dkey=" + Math.random()); } @Override public void beforeTrial(BenchmarkParams benchmarkParams) { // intentionally left blank } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { return Collections.emptyList(); } @Override public boolean allowPrintOut() { return true; } @Override public boolean allowPrintErr() { return true; } @Override public String getDescription() { return "Changing JVM Opts Integration Test External Profiler"; } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java000066400000000000000000000067761446271450100306060ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.*; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.lang.management.ManagementFactory; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class ChangeJVMOptsTest { public static final File TMP_FILE = new File(System.getProperty("java.io.tmpdir") + File.separator + "ChangingJVMOpts-list"); @Setup(Level.Trial) public void setup() { try { FileUtils.appendLines(TMP_FILE, Collections.singleton(ManagementFactory.getRuntimeMXBean().getInputArguments().toString())); } catch (IOException e) { throw new IllegalStateException(e); } } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(value = 5, warmups = 5) public void bench() { // intentionally left blank } @Test public void testExternal_API() throws RunnerException, IOException { prepare(); Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .warmupForks(5) .forks(5) .addProfiler(ChangeJVMOptsExternalProfiler.class) .build(); new Runner(opts).run(); check(); } @Test public void testExternal_CLI() throws RunnerException, CommandLineOptionException, IOException { prepare(); Options opts = new CommandLineOptions("-prof", ChangeJVMOptsExternalProfiler.class.getCanonicalName(), Fixtures.getTestMask(this.getClass())); new Runner(opts).run(); check(); } private void prepare() { TMP_FILE.delete(); } private void check() throws IOException { Set lines = new HashSet<>(); for (String line : FileUtils.readAllLines(TMP_FILE)) { if (!lines.add(line)) { Assert.fail("Duplicate line: " + line); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ClassloadProfilerTest.java000066400000000000000000000100471446271450100315700ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.ClassloaderProfiler; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) public class ClassloadProfilerTest { // Simplest Dummy class static final byte[] CLASS = new byte[] { (byte) 0xca, (byte) 0xfe, (byte) 0xba, (byte) 0xbe, 0x00, 0x00, 0x00, 0x34, 0x00, 0x0a, 0x0a, 0x00, 0x02, 0x00, 0x03, 0x07, 0x00, 0x04, 0x0c, 0x00, 0x05, 0x00, 0x06, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x07, 0x00, 0x08, 0x01, 0x00, 0x05, 0x44, 0x75, 0x6d, 0x6d, 0x79, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x00, 0x21, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x05, 0x00, 0x06, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, (byte) 0xb7, 0x00, 0x01, (byte) 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static class MyClassLoader extends ClassLoader { public Class loadClass(String name) throws ClassNotFoundException { if (name.equals("Dummy")) { return defineClass(name, CLASS, 0, CLASS.length, null); } else { return super.loadClass(name); } } } @Benchmark public Class work() throws Exception { Fixtures.work(); ClassLoader loader = new MyClassLoader(); return Class.forName("Dummy", true, loader); } @Test public void test() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(ClassloaderProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); double classLoad = ProfilerTestUtils.checkedGet(sr, "class.load.norm").getScore(); // Allow 5% slack if (Math.abs(1 - classLoad) > 0.05) { Assert.fail("Class loading rate is incorrect. Reported by profiler: " + classLoad); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CompilerProfilerTest.java000066400000000000000000000056771446271450100314520ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.CompilerProfiler; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) public class CompilerProfilerTest { @Benchmark public void work() { Fixtures.work(); } @Test public void test() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(CompilerProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); double timeTotal = ProfilerTestUtils.checkedGet(sr, "compiler.time.total").getScore(); double timeProfiled = ProfilerTestUtils.checkedGet(sr, "compiler.time.profiled").getScore(); if (timeProfiled > timeTotal) { throw new IllegalStateException("Profiled time is larger than total time. " + "Total: " + timeTotal + ", Profiled: " + timeProfiled); } if (timeProfiled <= 0) { throw new IllegalStateException("Should have profiled time: " + timeProfiled); } if (timeTotal <= 0) { throw new IllegalStateException("Should have total time: " + timeTotal); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfiler.java000066400000000000000000000056551446271450100323250ustar00rootroot00000000000000/* * Copyright (c) 2017, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.profile.ExternalProfiler; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.Result; import java.io.File; import java.util.Collection; import java.util.Collections; import java.util.concurrent.atomic.AtomicInteger; public class CountingExternalProfiler implements ExternalProfiler { static final AtomicInteger jvmOpts = new AtomicInteger(); static final AtomicInteger jvmInvokeOpts = new AtomicInteger(); static final AtomicInteger beforeTrial = new AtomicInteger(); static final AtomicInteger afterTrial = new AtomicInteger(); public static void reset() { jvmOpts.set(0); jvmInvokeOpts.set(0); beforeTrial.set(0); afterTrial.set(0); } @Override public boolean allowPrintErr() { return true; } @Override public boolean allowPrintOut() { return true; } @Override public Collection addJVMOptions(BenchmarkParams params) { jvmOpts.incrementAndGet(); return Collections.emptyList(); } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { jvmInvokeOpts.incrementAndGet(); return Collections.emptyList(); } @Override public void beforeTrial(BenchmarkParams benchmarkParams) { beforeTrial.incrementAndGet(); } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { afterTrial.incrementAndGet(); return Collections.emptyList(); } @Override public String getDescription() { return "Integration Test External Profiler with Stage Counting"; } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfilerTest.java000066400000000000000000000065431446271450100331620ustar00rootroot00000000000000/* * Copyright (c) 2017, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; public class CountingExternalProfilerTest { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void bench() { // intentionally left blank } @Test public void test() throws RunnerException { for (int warmupForks : new int[]{0, 1, 5}) { for (int forks : new int[]{1, 5}) { CountingExternalProfiler.reset(); Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(CountingExternalProfiler.class) .forks(forks) .warmupForks(warmupForks) .build(); new Runner(opts).run(); Assert.assertEquals("jvmOpts count is correct for warmupForks = " + warmupForks + ", and forks = " + forks, warmupForks + forks, CountingExternalProfiler.jvmOpts.get()); Assert.assertEquals("jvmInvokeOpts count is correct for warmupForks = " + warmupForks + ", and forks = " + forks, warmupForks + forks, CountingExternalProfiler.jvmInvokeOpts.get()); Assert.assertEquals("afterTrial count is correct for warmupForks = " + warmupForks + ", and forks = " + forks, warmupForks + forks, CountingExternalProfiler.afterTrial.get()); Assert.assertEquals("beforeTrial count is correct for warmupForks = " + warmupForks + ", and forks = " + forks, warmupForks + forks, CountingExternalProfiler.beforeTrial.get()); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DTraceAsmProfilerTest.java000066400000000000000000000050201446271450100314610ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Test; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.DTraceAsmProfiler; import org.openjdk.jmh.profile.ProfilerException; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; public class DTraceAsmProfilerTest extends AbstractAsmProfilerTest { @Test public void test() throws RunnerException { try { new DTraceAsmProfiler(""); } catch (ProfilerException e) { System.out.println("Profiler is not supported or cannot be enabled, skipping test"); return; } Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(DTraceAsmProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); String out = ProfilerTestUtils.checkedGet(sr, "asm").extendedInfo(); if (!checkDisassembly(out)) { throw new IllegalStateException("Profile does not contain the required frame: " + out); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DuplicateProfilerTest.java000066400000000000000000000106341446271450100315770ustar00rootroot00000000000000/* * Copyright (c) 2017, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.CommandLineOptionException; import org.openjdk.jmh.runner.options.CommandLineOptions; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; public class DuplicateProfilerTest { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void bench() { // intentionally left blank } @Test public void testInternal_API() { try { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(ItInternalProfiler.class) .addProfiler(ItInternalProfiler.class) .build(); new Runner(opts).run(); Assert.fail("Expected to fail"); } catch (RunnerException e) { String msg = e.getMessage(); Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler")); } } @Test public void testExternal_API() { try { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(ItExternalProfiler.class) .addProfiler(ItExternalProfiler.class) .build(); new Runner(opts).run(); Assert.fail("Expected to fail"); } catch (RunnerException e) { String msg = e.getMessage(); Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler")); } } @Test public void testInternal_CLI() throws CommandLineOptionException { try { Options opts = new CommandLineOptions( "-prof", ItInternalProfiler.class.getCanonicalName(), "-prof", ItInternalProfiler.class.getCanonicalName(), Fixtures.getTestMask(this.getClass())); new Runner(opts).run(); Assert.fail("Expected to fail"); } catch (RunnerException e) { String msg = e.getMessage(); Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler")); } } @Test public void testExternal_CLI() throws CommandLineOptionException { try { Options opts = new CommandLineOptions( "-prof", ItExternalProfiler.class.getCanonicalName(), "-prof", ItExternalProfiler.class.getCanonicalName(), Fixtures.getTestMask(this.getClass())); new Runner(opts).run(); Assert.fail("Expected to fail"); } catch (RunnerException e) { String msg = e.getMessage(); Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler")); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java000066400000000000000000000070121446271450100317410ustar00rootroot00000000000000/* * Copyright (c) 2022, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.GCProfiler; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collection; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) public class GCProfilerAllocRateTest { @Benchmark public Object allocate() { return new byte[1000]; } @Test public void testDefault() throws RunnerException { testWith(""); } @Test public void testAlloc() throws RunnerException { testWith("alloc=true"); } @Test public void testAll() throws RunnerException { testWith("alloc=true;churn=true"); } private void testWith(String initLine) throws RunnerException { if (!Fixtures.expectStableThreads()) { // This test assumes threads survive until the end of run to get their // allocation data. return; } Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(GCProfiler.class, initLine) .build(); RunResult rr = new Runner(opts).runSingle(); double opsPerSec = rr.getPrimaryResult().getScore(); Map sr = rr.getSecondaryResults(); double allocRateMB = ProfilerTestUtils.checkedGet(sr, "gc.alloc.rate").getScore(); double allocRateNormB = ProfilerTestUtils.checkedGet(sr, "gc.alloc.rate.norm").getScore(); double allocRatePrimaryMB = opsPerSec * allocRateNormB / 1024 / 1024; // Allow 20% slack if (Math.abs(1 - allocRatePrimaryMB / allocRateMB) > 0.2) { Assert.fail("Allocation rates disagree. " + "Reported by profiler: " + allocRateMB + ", computed from primary score: " + allocRatePrimaryMB); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java000066400000000000000000000071501446271450100327720ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.GCProfiler; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.util.JDKVersion; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(value = 1, jvmArgs = {"-Xms1g", "-Xmx1g", "-XX:+UseParallelGC"}) @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) public class GCProfilerSeparateThreadTest { static final int SIZE = 1_000_000; @Benchmark public void separateAlloc(Blackhole bh) throws InterruptedException { Thread t = new Thread(() -> bh.consume(new byte[SIZE])); t.start(); t.join(); } @Test public void testDefault() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(GCProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); double allocRateNormB = ProfilerTestUtils.checkedGet(sr, "gc.alloc.rate.norm").getScore(); String msg = "Reported by profiler: " + allocRateNormB + ", target: " + SIZE; // Allow 1% slack if (accurateProfiler() && (Math.abs(1 - allocRateNormB / SIZE) > 0.01)) { Assert.fail("Allocation rate failure. Reported by profiler: " + allocRateNormB + ", target: " + SIZE); } System.out.println(msg); } private boolean accurateProfiler() { // Change to this version-sensing code after JDK 21 releases: // return JDKVersion.parseMajor(System.getProperty("java.version")) >= 21; // Try to sense the existence of the accurate method: try { Class.forName("com.sun.management.ThreadMXBean").getMethod("getTotalThreadAllocatedBytes"); return true; } catch (Exception e) { // Fall through } return false; } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerTest.java000066400000000000000000000075651446271450100301670ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.GCProfiler; import org.openjdk.jmh.profile.ProfilerException; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @OutputTimeUnit(TimeUnit.NANOSECONDS) @Fork(1) // 0 to enable debugging public class GCProfilerTest { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.MILLISECONDS) @BenchmarkMode(Mode.AverageTime) public Object allocateObjectNoWarmup() { return new Object(); } @Benchmark @Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 2, time = 2, timeUnit = TimeUnit.SECONDS) @BenchmarkMode(Mode.AverageTime) public Object allocateObject() { return new Object(); } @Benchmark @Warmup(iterations = 2) @Measurement(iterations = 5) @BenchmarkMode(Mode.SingleShotTime) public Object allocateObjectSingleShot() { return new Object(); } @Benchmark @Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 1, time = 2, timeUnit = TimeUnit.SECONDS) @BenchmarkMode(Mode.SampleTime) public Object allocateObjectSampleTime() { return new Object(); } @Test public void testDefault() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(GCProfiler.class) .build(); new Runner(opts).run(); } @Test public void testAlloc() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(GCProfiler.class, "alloc=true") .build(); new Runner(opts).run(); } @Test public void testChurn() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(GCProfiler.class, "churn=true;churnWait=1") .build(); new Runner(opts).run(); } @Test public void testAll() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(GCProfiler.class, "alloc=true;churn=true;churnWait=1") .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ItExternalProfiler.java000066400000000000000000000047001446271450100311010ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.profile.ExternalProfiler; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.Result; import java.io.File; import java.util.Collection; import java.util.Collections; public class ItExternalProfiler implements ExternalProfiler { @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public Collection addJVMOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public void beforeTrial(BenchmarkParams benchmarkParams) { // intentionally left blank } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { Assert.assertFalse("Forked VM PID is not 0", pid == 0); return Collections.emptyList(); } @Override public boolean allowPrintOut() { return true; } @Override public boolean allowPrintErr() { return true; } @Override public String getDescription() { return "Integration Test External Profiler"; } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ItInternalProfiler.java000066400000000000000000000040341446271450100310730ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.profile.InternalProfiler; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.results.Result; import java.util.Collection; import java.util.Collections; public class ItInternalProfiler implements InternalProfiler { @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { // intentionally blank } @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { return Collections.emptyList(); } @Override public String getDescription() { return "Integration Test Internal Profiler"; } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/JavaFlightRecorderProfilerTest.java000066400000000000000000000044411446271450100333710ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.CompilerProfiler; import org.openjdk.jmh.profile.JavaFlightRecorderProfiler; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) public class JavaFlightRecorderProfilerTest { @Benchmark public void work() { Fixtures.work(); } @Test public void test() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(JavaFlightRecorderProfiler.class) .build(); new Runner(opts).runSingle(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfAsmProfilerTest.java000066400000000000000000000050341446271450100322400ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Test; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.LinuxPerfAsmProfiler; import org.openjdk.jmh.profile.ProfilerException; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; public class LinuxPerfAsmProfilerTest extends AbstractAsmProfilerTest { @Test public void test() throws RunnerException { try { new LinuxPerfAsmProfiler(""); } catch (ProfilerException e) { System.out.println("Profiler is not supported or cannot be enabled, skipping test"); return; } Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(LinuxPerfAsmProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); String out = ProfilerTestUtils.checkedGet(sr, "asm").extendedInfo(); if (!checkDisassembly(out)) { throw new IllegalStateException("Profile does not contain the required frame: " + out); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfC2CProfilerTest.java000066400000000000000000000055201446271450100320670ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.LinuxPerfC2CProfiler; import org.openjdk.jmh.profile.ProfilerException; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) public class LinuxPerfC2CProfilerTest { @Benchmark public void work() { somethingInTheMiddle(); } @CompilerControl(CompilerControl.Mode.DONT_INLINE) public void somethingInTheMiddle() { Fixtures.work(); } @Test public void test() throws RunnerException { try { new LinuxPerfC2CProfiler(); } catch (ProfilerException e) { System.out.println("Profiler is not supported or cannot be enabled, skipping test"); return; } Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(LinuxPerfC2CProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); String text = ProfilerTestUtils.checkedGet(sr, "perfc2c").extendedInfo(); Assert.assertNotNull(text); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java000066400000000000000000000071701446271450100324360ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.LinuxPerfNormProfiler; import org.openjdk.jmh.profile.ProfilerException; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) public class LinuxPerfNormProfilerTest { @Benchmark public void work() { somethingInTheMiddle(); } @CompilerControl(CompilerControl.Mode.DONT_INLINE) public void somethingInTheMiddle() { Blackhole.consumeCPU(1); } @Test public void test() throws RunnerException { try { new LinuxPerfNormProfiler(""); } catch (ProfilerException e) { System.out.println("Profiler is not supported or cannot be enabled, skipping test"); return; } Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(LinuxPerfNormProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); double instructions = ProfilerTestUtils.checkedGet(sr, "instructions", "instructions:u").getScore(); double cycles = ProfilerTestUtils.checkedGet(sr, "cycles", "cycles:u").getScore(); double branches = ProfilerTestUtils.checkedGet(sr, "branches", "branches:u").getScore(); Assert.assertNotEquals(0D, instructions, 0D); Assert.assertNotEquals(0D, cycles, 0D); Assert.assertNotEquals(0D, branches, 0D); if (branches > instructions) { throw new IllegalStateException(String.format("Branches (%.2f) larger than instructions (%.3f)", branches, instructions)); } double ipc = ProfilerTestUtils.checkedGet(sr, "IPC").getScore(); double cpi = ProfilerTestUtils.checkedGet(sr, "CPI").getScore(); Assert.assertNotEquals(0D, ipc, 0D); Assert.assertNotEquals(0D, cpi, 0D); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java000066400000000000000000000065201446271450100316000ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.LinuxPerfAsmProfiler; import org.openjdk.jmh.profile.LinuxPerfProfiler; import org.openjdk.jmh.profile.ProfilerException; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) public class LinuxPerfProfilerTest { @Benchmark public void work() { somethingInTheMiddle(); } @CompilerControl(CompilerControl.Mode.DONT_INLINE) public void somethingInTheMiddle() { Blackhole.consumeCPU(1); } @Test public void test() throws RunnerException { try { new LinuxPerfProfiler(""); } catch (ProfilerException e) { System.out.println("Profiler is not supported or cannot be enabled, skipping test"); return; } Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(LinuxPerfProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); String msg = ProfilerTestUtils.checkedGet(sr, "perf").extendedInfo(); if (sr.containsKey("ipc")) { double ipc = ProfilerTestUtils.checkedGet(sr, "ipc").getScore(); double cpi = ProfilerTestUtils.checkedGet(sr, "cpi").getScore(); Assert.assertNotEquals(0D, ipc, 0D); Assert.assertNotEquals(0D, cpi, 0D); } Assert.assertTrue(msg.contains("cycles")); Assert.assertTrue(msg.contains("instructions")); Assert.assertTrue(msg.contains("branches")); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/MemPoolProfilerTest.java000066400000000000000000000066341446271450100312420ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.CompilerProfiler; import org.openjdk.jmh.profile.MemPoolProfiler; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) public class MemPoolProfilerTest { @Benchmark public void work() { Fixtures.work(); } @Test public void test() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(MemPoolProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); double usedMetaspace = ProfilerTestUtils.checkedGet(sr, "mempool.Metaspace.used").getScore(); double usedTotal = ProfilerTestUtils.checkedGet(sr, "mempool.total.used").getScore(); double usedTotalCodeheap = ProfilerTestUtils.checkedGet(sr, "mempool.total.codeheap.used").getScore(); if (usedMetaspace == 0) { throw new IllegalStateException("Metaspace used is zero"); } if (usedTotal == 0) { throw new IllegalStateException("Total used is zero"); } if (usedTotalCodeheap == 0) { throw new IllegalStateException("Total codeheap used is zero"); } if (usedMetaspace > usedTotal) { throw new IllegalStateException("Metaspace size is larger than total size. " + "Total: " + usedTotal + ", Metaspace: " + usedMetaspace); } if (usedTotalCodeheap > usedTotal) { throw new IllegalStateException("Codeheap size is larger than total size. " + "Total: " + usedTotal + ", Codeheap: " + usedTotalCodeheap); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ProfilerTest.java000066400000000000000000000062241446271450100277440ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.CommandLineOptionException; import org.openjdk.jmh.runner.options.CommandLineOptions; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; public class ProfilerTest { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void bench() { // intentionally left blank } @Test public void testInternal_API() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(ItInternalProfiler.class) .build(); new Runner(opts).run(); } @Test public void testExternal_API() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(ItExternalProfiler.class) .build(); new Runner(opts).run(); } @Test public void testInternal_CLI() throws RunnerException, CommandLineOptionException { Options opts = new CommandLineOptions("-prof", ItInternalProfiler.class.getCanonicalName(), Fixtures.getTestMask(this.getClass())); new Runner(opts).run(); } @Test public void testExternal_CLI() throws RunnerException, CommandLineOptionException { Options opts = new CommandLineOptions("-prof", ItExternalProfiler.class.getCanonicalName(), Fixtures.getTestMask(this.getClass())); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ProfilerTestUtils.java000066400000000000000000000036741446271450100307730ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.openjdk.jmh.results.Result; import java.util.Arrays; import java.util.Map; public class ProfilerTestUtils { public static Result checkedGet(Map sr, String... names) { for (String name : names) { Result r = sr.get(name); if (r != null) { return r; } } StringBuilder sb = new StringBuilder(); for (String k : sr.keySet()) { sb.append(k); sb.append(" = "); sb.append(sr.get(k)); sb.append(System.lineSeparator()); } throw new IllegalStateException("Cannot find the result for " + Arrays.toString(names) + "\". Available entries: " + sb); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java000066400000000000000000000112011446271450100317670ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.MemPoolProfiler; import org.openjdk.jmh.profile.SafepointsProfiler; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(value = 1, jvmArgsAppend = {"-Xms1g", "-Xmx1g"}) public class SafepointsProfilerTest { @Benchmark public int[] allocate() { return new int[1_000_000]; } @Test public void test() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(SafepointsProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); double interval = ProfilerTestUtils.checkedGet(sr, "safepoints.interval").getScore(); double pauseTotal = ProfilerTestUtils.checkedGet(sr, "safepoints.pause").getScore(); double ttspTotal = ProfilerTestUtils.checkedGet(sr, "safepoints.ttsp").getScore(); double pauseCount = ProfilerTestUtils.checkedGet(sr, "safepoints.pause.count").getScore(); double ttspCount = ProfilerTestUtils.checkedGet(sr, "safepoints.ttsp.count").getScore(); Assert.assertNotEquals(0D, pauseTotal, 0D); Assert.assertNotEquals(0D, ttspTotal, 0D); Assert.assertNotEquals(0D, pauseCount, 0D); Assert.assertNotEquals(0D, ttspCount, 0D); Assert.assertEquals(ttspCount, pauseCount, 0D); if (interval < 3000) { throw new IllegalStateException("Interval time is too low. " + " Interval: " + interval); } if (ttspTotal > interval) { throw new IllegalStateException("TTSP time is larger than interval time. " + "TTSP: " + ttspTotal + ", Interval: " + interval); } if (pauseTotal > interval) { throw new IllegalStateException("Pause time is larger than interval time. " + "Pause: " + pauseTotal + ", Interval: " + interval); } if (ttspTotal > pauseTotal) { throw new IllegalStateException("TTSP time is larger than pause time. " + "TTSP: " + ttspTotal + ", Pause: " + pauseTotal); } double lastPause = 0; double lastTTSP = 0; for (String suff : new String[] {"0.00", "0.50", "0.90", "0.95", "0.99", "0.999", "0.9999", "1.00"}) { double curPause = ProfilerTestUtils.checkedGet(sr, "safepoints.pause.p" + suff).getScore(); double curTTSP = ProfilerTestUtils.checkedGet(sr, "safepoints.ttsp.p" + suff).getScore(); if (curPause < lastPause) { throw new IllegalStateException("pause.p" + suff + " is not monotonic"); } if (curTTSP < lastTTSP) { throw new IllegalStateException("ttsp.p" + suff + " is not monotonic"); } lastPause = curPause; lastTTSP = curTTSP; } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/StackProfilerTest.java000066400000000000000000000056441446271450100307370ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.JavaFlightRecorderProfiler; import org.openjdk.jmh.profile.StackProfiler; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; import java.util.concurrent.TimeUnit; @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) public class StackProfilerTest { @Benchmark public void work() { somethingInTheMiddle(); } @CompilerControl(CompilerControl.Mode.DONT_INLINE) public void somethingInTheMiddle() { Fixtures.work(); } @Test public void test() throws RunnerException { if (Fixtures.isVirtualExecutor()) { System.out.println("Stack profiler is not reliable with virtual threads"); return; } Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(StackProfiler.class, "lines=10") .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); String out = ProfilerTestUtils.checkedGet(sr, "stack").extendedInfo(); if (!out.contains(StackProfilerTest.class.getCanonicalName() + ".somethingInTheMiddle")) { throw new IllegalStateException("Profile does not contain the required frame: " + out); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/WinPerfAsmProfilerTest.java000066400000000000000000000050241446271450100316750ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers; import org.junit.Test; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.profile.ProfilerException; import org.openjdk.jmh.profile.WinPerfAsmProfiler; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Map; public class WinPerfAsmProfilerTest extends AbstractAsmProfilerTest { @Test public void test() throws RunnerException { try { new WinPerfAsmProfiler(""); } catch (ProfilerException e) { System.out.println("Profiler is not supported or cannot be enabled, skipping test"); return; } Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(WinPerfAsmProfiler.class) .build(); RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); String out = ProfilerTestUtils.checkedGet(sr, "asm").extendedInfo(); if (!checkDisassembly(out)) { throw new IllegalStateException("Profile does not contain the required frame: " + out); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/000077500000000000000000000000001446271450100255665ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/AbstractExternalProfiler.java000066400000000000000000000060141446271450100334030ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers.order; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.profile.ExternalProfiler; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.Result; import java.io.File; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.concurrent.TimeUnit; public abstract class AbstractExternalProfiler implements ExternalProfiler { private final String pfx; protected long start, stop; protected AbstractExternalProfiler(String pfx) { this.pfx = pfx; } @Override public boolean allowPrintErr() { return true; } @Override public boolean allowPrintOut() { return true; } @Override public Collection addJVMOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public void beforeTrial(BenchmarkParams benchmarkParams) { start = System.nanoTime(); try { TimeUnit.MILLISECONDS.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { stop = System.nanoTime(); try { TimeUnit.MILLISECONDS.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } return Arrays.asList( new ProfilerTimestamp(pfx + "start", start), new ProfilerTimestamp(pfx + "stop", stop) ); } @Override public String getDescription() { return "Integration Test External Profiler"; } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/AbstractInternalProfiler.java000066400000000000000000000052501446271450100333760ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers.order; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.profile.InternalProfiler; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.results.Result; import java.util.Arrays; import java.util.Collection; import java.util.concurrent.TimeUnit; public abstract class AbstractInternalProfiler implements InternalProfiler { private final String pfx; protected long start, stop; protected AbstractInternalProfiler(String pfx) { this.pfx = pfx; } @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { start = System.nanoTime(); try { TimeUnit.MILLISECONDS.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { stop = System.nanoTime(); try { TimeUnit.MILLISECONDS.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } return Arrays.asList( new ProfilerTimestamp(pfx + "start", start), new ProfilerTimestamp(pfx + "stop", stop) ); } @Override public String getDescription() { return "Integration Test Internal Profiler"; } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ExternalProfiler1.java000066400000000000000000000025551446271450100320060ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers.order; public class ExternalProfiler1 extends AbstractExternalProfiler { public ExternalProfiler1() { super("prof1"); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ExternalProfiler2.java000066400000000000000000000025551446271450100320070ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers.order; public class ExternalProfiler2 extends AbstractExternalProfiler { public ExternalProfiler2() { super("prof2"); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ExternalProfiler3.java000066400000000000000000000025551446271450100320100ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers.order; public class ExternalProfiler3 extends AbstractExternalProfiler { public ExternalProfiler3() { super("prof3"); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/InternalProfiler1.java000066400000000000000000000025551446271450100320000ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers.order; public class InternalProfiler1 extends AbstractInternalProfiler { public InternalProfiler1() { super("prof1"); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/InternalProfiler2.java000066400000000000000000000025551446271450100320010ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers.order; public class InternalProfiler2 extends AbstractInternalProfiler { public InternalProfiler2() { super("prof2"); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/InternalProfiler3.java000066400000000000000000000025551446271450100320020ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers.order; public class InternalProfiler3 extends AbstractInternalProfiler { public InternalProfiler3() { super("prof3"); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ProfilerOrderTest.java000066400000000000000000000114361446271450100320540ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers.order; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.CommandLineOptionException; import org.openjdk.jmh.runner.options.CommandLineOptions; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collection; import java.util.Map; import java.util.concurrent.TimeUnit; public class ProfilerOrderTest { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void bench() { // intentionally left blank } @Test public void testInternal_API() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(InternalProfiler1.class) .addProfiler(InternalProfiler2.class) .addProfiler(InternalProfiler3.class) .build(); runWith(opts); } @Test public void testInternal_CLI() throws RunnerException, CommandLineOptionException { CommandLineOptions opts = new CommandLineOptions( Fixtures.getTestMask(this.getClass()), "-prof", InternalProfiler1.class.getCanonicalName(), "-prof", InternalProfiler2.class.getCanonicalName(), "-prof", InternalProfiler3.class.getCanonicalName() ); runWith(opts); } @Test public void testExternal_API() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(ExternalProfiler1.class) .addProfiler(ExternalProfiler2.class) .addProfiler(ExternalProfiler3.class) .build(); runWith(opts); } @Test public void testExternal_CLI() throws RunnerException, CommandLineOptionException { CommandLineOptions opts = new CommandLineOptions( Fixtures.getTestMask(this.getClass()), "-prof", ExternalProfiler1.class.getCanonicalName(), "-prof", ExternalProfiler2.class.getCanonicalName(), "-prof", ExternalProfiler3.class.getCanonicalName() ); runWith(opts); } private void runWith(Options opts) throws RunnerException {Collection results = new Runner(opts).run(); for (RunResult r : results) { Map sec = r.getSecondaryResults(); double prof1start = sec.get("prof1start").getScore(); double prof2start = sec.get("prof2start").getScore(); double prof3start = sec.get("prof3start").getScore(); double prof1stop = sec.get("prof1stop").getScore(); double prof2stop = sec.get("prof2stop").getScore(); double prof3stop = sec.get("prof3stop").getScore(); Assert.assertTrue("start(1) < start(2)", prof1start < prof2start); Assert.assertTrue("start(2) < start(3)", prof2start < prof3start); Assert.assertTrue("stop(3) < stop(2)", prof3stop < prof2stop); Assert.assertTrue("stop(2) < stop(1)", prof2stop < prof1stop); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ProfilerTimestamp.java000066400000000000000000000045421446271450100321040ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.profilers.order; import org.openjdk.jmh.results.AggregationPolicy; import org.openjdk.jmh.results.Aggregator; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.ResultRole; import java.util.Collection; public class ProfilerTimestamp extends Result { public ProfilerTimestamp(String label, double ts) { super(ResultRole.SECONDARY, label, of(ts), "N/A", AggregationPolicy.MAX); } @Override protected Aggregator getThreadAggregator() { return new LogAggregator(); } @Override protected Aggregator getIterationAggregator() { return new LogAggregator(); } public static class LogAggregator implements Aggregator { @Override public ProfilerTimestamp aggregate(Collection results) { String label = null; double d = Double.MIN_VALUE; for (ProfilerTimestamp r : results) { label = r.label; d = Math.max(d, r.getScore()); } return new ProfilerTimestamp(label, d); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/000077500000000000000000000000001446271450100235435ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceBenchmarkStateInvocationTest.java000066400000000000000000000064131446271450100327720ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.races; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class RaceBenchmarkStateInvocationTest { @State(Scope.Benchmark) public static class MyState { public int value = 2; @Setup(Level.Invocation) public void setup() { Assert.assertEquals("Setup", 2, value); value = 1; } @TearDown(Level.Invocation) public void tearDown() { Assert.assertEquals("TearDown", 1, value); value = 2; } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Threads(4) public void test(MyState state) { // Useless to test this condition here, intrinsic races. // Assert.assertEquals("Run", 1, state.value); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceBenchmarkStateIterationTest.java000066400000000000000000000063141446271450100326170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.races; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class RaceBenchmarkStateIterationTest { @State(Scope.Benchmark) public static class MyState { public int value = 2; @Setup(Level.Iteration) public void setup() { Assert.assertEquals("Setup", 2, value); value = 1; } @TearDown(Level.Iteration) public void tearDown() { Assert.assertEquals("TearDown", 1, value); value = 2; } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 50, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Threads(4) public void test(MyState state) { Assert.assertEquals("Run", 1, state.value); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceBenchmarkStateRunTest.java000066400000000000000000000062761446271450100314340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.races; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class RaceBenchmarkStateRunTest { @State(Scope.Benchmark) public static class MyState { public int value = 2; @Setup(Level.Trial) public void setup() { Assert.assertEquals("Setup", 2, value); value = 1; } @TearDown(Level.Trial) public void tearDown() { Assert.assertEquals("TearDown", 1, value); value = 2; } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Threads(4) public void test(MyState state) { Assert.assertEquals("Run", 1, state.value); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateInvocationTest.java000066400000000000000000000065061446271450100321770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.races; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class RaceGroupStateInvocationTest { @State(Scope.Group) public static class MyState { public int value = 2; @Setup(Level.Invocation) public void setup() { Assert.assertEquals("Setup", 2, value); value = 1; } @TearDown(Level.Invocation) public void tearDown() { Assert.assertEquals("TearDown", 1, value); value = 2; } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Group("T") @GroupThreads(4) public void test(MyState state) { // Useless to test this condition here, intrinsic races. // Assert.assertEquals("Run", 1, state.value); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateIterationTest.java000066400000000000000000000064101446271450100320160ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.races; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class RaceGroupStateIterationTest { @State(Scope.Group) public static class MyState { public int value = 2; @Setup(Level.Iteration) public void setup() { Assert.assertEquals("Setup", 2, value); value = 1; } @TearDown(Level.Iteration) public void tearDown() { Assert.assertEquals("TearDown", 1, value); value = 2; } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 50, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Group("T") @GroupThreads(4) public void test(MyState state) { Assert.assertEquals("Run", 1, state.value); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceGroupStateRunTest.java000066400000000000000000000063721446271450100306330ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.races; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class RaceGroupStateRunTest { @State(Scope.Group) public static class MyState { public int value = 2; @Setup(Level.Trial) public void setup() { Assert.assertEquals("Setup", 2, value); value = 1; } @TearDown(Level.Trial) public void tearDown() { Assert.assertEquals("TearDown", 1, value); value = 2; } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Group("T") @GroupThreads(4) public void test(MyState state) { Assert.assertEquals("Run", 1, state.value); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceThreadStateInvocationTest.java000066400000000000000000000063021446271450100323040ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.races; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class RaceThreadStateInvocationTest { @State(Scope.Thread) public static class MyState { public int value = 2; @Setup(Level.Invocation) public void setup() { Assert.assertEquals("Setup", 2, value); value = 1; } @TearDown(Level.Invocation) public void tearDown() { Assert.assertEquals("TearDown", 1, value); value = 2; } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Threads(4) public void test(MyState state) { Assert.assertEquals("Run", 1, state.value); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceThreadStateIterationTest.java000066400000000000000000000063061446271450100321350ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.races; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class RaceThreadStateIterationTest { @State(Scope.Thread) public static class MyState { public int value = 2; @Setup(Level.Iteration) public void setup() { Assert.assertEquals("Setup", 2, value); value = 1; } @TearDown(Level.Iteration) public void tearDown() { Assert.assertEquals("TearDown", 1, value); value = 2; } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 50, time = 10, timeUnit = TimeUnit.MILLISECONDS) @Threads(4) public void test(MyState state) { Assert.assertEquals("Run", 1, state.value); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceThreadStateRunTest.java000066400000000000000000000062701446271450100307430ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.races; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; /** * Baseline test: * Checks if assertions are propagated back to integration tests. */ public class RaceThreadStateRunTest { @State(Scope.Thread) public static class MyState { public int value = 2; @Setup(Level.Trial) public void setup() { Assert.assertEquals("Setup", 2, value); value = 1; } @TearDown(Level.Trial) public void tearDown() { Assert.assertEquals("TearDown", 1, value); value = 2; } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Threads(4) public void test(MyState state) { Assert.assertEquals("Run", 1, state.value); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .forks(0) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/result/000077500000000000000000000000001446271450100237645ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/result/ResultFileNameTest.java000066400000000000000000000063271446271450100303560ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.result; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.io.File; import java.io.IOException; import java.util.concurrent.TimeUnit; /** * Tests if harness favors the iteration count annotations. */ @State(Scope.Thread) public class ResultFileNameTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void testLower() throws RunnerException, IOException { doWith("jmh" + this.getClass().getSimpleName().toLowerCase() + ".result"); } @Test public void testUpper() throws RunnerException, IOException { doWith("JMH" + this.getClass().getSimpleName().toUpperCase() + ".RESULT"); } @Test public void testMixed() throws RunnerException, IOException { doWith("jmh" + this.getClass().getSimpleName() + ".result"); } public void doWith(String name) throws RunnerException, IOException { name = System.getProperty("java.io.tmpdir") + File.separator + name; Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .result(name) .build(); new Runner(opts).run(); File file = new File(name); Assert.assertTrue(file.exists()); file.delete(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/000077500000000000000000000000001446271450100243155ustar00rootroot00000000000000BenchmarkMinJVMArgsSecurityManagerTest.java000066400000000000000000000054501446271450100345200ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class BenchmarkMinJVMArgsSecurityManagerTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException, URISyntaxException, NoSuchAlgorithmException { URI policyFile = BenchmarkMinJVMArgsSecurityManagerTest.class.getResource("/jmh-security-minimal-runner.policy").toURI(); Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .jvmArgsAppend("-Djava.security.manager", "-Djava.security.policy=" + policyFile.toString()) .build(); new Runner(opts).run(); } } BenchmarkMinRunnerSecurityManagerTest.java000066400000000000000000000057561446271450100345310ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.security.Policy; import java.security.URIParameter; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class BenchmarkMinRunnerSecurityManagerTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException, URISyntaxException, NoSuchAlgorithmException { URI policyFile = BenchmarkMinRunnerSecurityManagerTest.class.getResource("/jmh-security-minimal-runner.policy").toURI(); Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile))); SecurityManagerTestUtils.install(); try { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } finally { SecurityManagerTestUtils.remove(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/BenchmarkMinSecurityManagerTest.java000066400000000000000000000062231446271450100334040ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.security.Policy; import java.security.URIParameter; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class BenchmarkMinSecurityManagerTest { @Setup public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException { Fixtures.work(); URI policyFile = BenchmarkMinSecurityManagerTest.class.getResource("/jmh-security-minimal.policy").toURI(); Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile))); SecurityManagerTestUtils.install(); } @TearDown public void tearDown() { SecurityManagerTestUtils.remove(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/BenchmarkSecurityManagerTest.java000066400000000000000000000062051446271450100327400ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.security.Policy; import java.security.URIParameter; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class BenchmarkSecurityManagerTest { @Setup public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException { Fixtures.work(); URI policyFile = BenchmarkSecurityManagerTest.class.getResource("/jmh-security.policy").toURI(); Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile))); SecurityManagerTestUtils.install(); } @TearDown public void tearDown() { SecurityManagerTestUtils.remove(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } GroupMinJVMArgsSecurityManagerTest.java000066400000000000000000000056411446271450100337240ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.util.concurrent.TimeUnit; @State(Scope.Group) public class GroupMinJVMArgsSecurityManagerTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("group1") @GroupThreads(2) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException, URISyntaxException, NoSuchAlgorithmException { URI policyFile = GroupMinJVMArgsSecurityManagerTest.class.getResource("/jmh-security-minimal-runner.policy").toURI(); Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .jvmArgsAppend("-Djava.security.manager", "-Djava.security.policy=" + policyFile.toString()) .build(); new Runner(opts).run(); } } GroupMinRunnerSecurityManagerTest.java000066400000000000000000000061501446271450100337200ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.security.Policy; import java.security.URIParameter; import java.util.concurrent.TimeUnit; @State(Scope.Group) public class GroupMinRunnerSecurityManagerTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("group1") @GroupThreads(2) public void test1() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException, URISyntaxException, NoSuchAlgorithmException { URI policyFile = GroupMinRunnerSecurityManagerTest.class.getResource("/jmh-security-minimal-runner.policy").toURI(); Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile))); SecurityManagerTestUtils.install(); try { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } finally { SecurityManagerTestUtils.remove(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/GroupMinSecurityManagerTest.java000066400000000000000000000064151446271450100326110ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.security.Policy; import java.security.URIParameter; import java.util.concurrent.TimeUnit; @State(Scope.Group) public class GroupMinSecurityManagerTest { @Setup public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException { Fixtures.work(); URI policyFile = GroupMinSecurityManagerTest.class.getResource("/jmh-security-minimal.policy").toURI(); Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile))); SecurityManagerTestUtils.install(); } @TearDown public void tearDown() { SecurityManagerTestUtils.remove(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("group1") @GroupThreads(2) public void test1() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/GroupSecurityManagerTest.java000066400000000000000000000063771446271450100321540ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.security.Policy; import java.security.URIParameter; import java.util.concurrent.TimeUnit; @State(Scope.Group) public class GroupSecurityManagerTest { @Setup public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException { Fixtures.work(); URI policyFile = GroupSecurityManagerTest.class.getResource("/jmh-security.policy").toURI(); Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile))); SecurityManagerTestUtils.install(); } @TearDown public void tearDown() { SecurityManagerTestUtils.remove(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("group1") @GroupThreads(2) public void test1() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/SecurityManagerTestUtils.java000066400000000000000000000042311446271450100321430ustar00rootroot00000000000000/* * Copyright (c) 2022, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import java.security.AccessController; import java.security.PrivilegedAction; public class SecurityManagerTestUtils { public static void install() { try { AccessController.doPrivileged(new PrivilegedAction() { public Void run() { System.setSecurityManager(new SecurityManager()); return null; } }); } catch (UnsupportedOperationException uoe) { // Probably modern JDK without SecurityManager support. } } public static void remove() { try { AccessController.doPrivileged(new PrivilegedAction() { public Void run() { System.setSecurityManager(null); return null; } }); } catch (UnsupportedOperationException uoe) { // Probably modern JDK without SecurityManager support. } } } ThreadMinJVMArgsSecurityManagerTest.java000066400000000000000000000054371446271450100340420ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.util.concurrent.TimeUnit; @State(Scope.Thread) public class ThreadMinJVMArgsSecurityManagerTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException, URISyntaxException, NoSuchAlgorithmException { URI policyFile = ThreadMinJVMArgsSecurityManagerTest.class.getResource("/jmh-security-minimal-runner.policy").toURI(); Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .jvmArgsAppend("-Djava.security.manager", "-Djava.security.policy=" + policyFile.toString()) .build(); new Runner(opts).run(); } } ThreadMinRunnerSecurityManagerTest.java000066400000000000000000000057451446271450100340440ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.security.Policy; import java.security.URIParameter; import java.util.concurrent.TimeUnit; @State(Scope.Thread) public class ThreadMinRunnerSecurityManagerTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException, URISyntaxException, NoSuchAlgorithmException { URI policyFile = ThreadMinRunnerSecurityManagerTest.class.getResource("/jmh-security-minimal-runner.policy").toURI(); Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile))); SecurityManagerTestUtils.install(); try { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } finally { SecurityManagerTestUtils.remove(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/ThreadMinSecurityManagerTest.java000066400000000000000000000062121446271450100327170ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.security.Policy; import java.security.URIParameter; import java.util.concurrent.TimeUnit; @State(Scope.Thread) public class ThreadMinSecurityManagerTest { @Setup public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException { Fixtures.work(); URI policyFile = ThreadMinSecurityManagerTest.class.getResource("/jmh-security-minimal.policy").toURI(); Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile))); SecurityManagerTestUtils.install(); } @TearDown public void tearDown() { SecurityManagerTestUtils.remove(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/ThreadSecurityManagerTest.java000066400000000000000000000061741446271450100322620ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.security; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.security.Policy; import java.security.URIParameter; import java.util.concurrent.TimeUnit; @State(Scope.Thread) public class ThreadSecurityManagerTest { @Setup public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException { Fixtures.work(); URI policyFile = ThreadSecurityManagerTest.class.getResource("/jmh-security.policy").toURI(); Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile))); SecurityManagerTestUtils.install(); } @TearDown public void tearDown() { SecurityManagerTestUtils.remove(); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/separatecl/000077500000000000000000000000001446271450100245715ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/separatecl/SeparateClassLoaderTest.java000066400000000000000000000043541446271450100321630ustar00rootroot00000000000000/* * Copyright (c) 2021, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.separatecl; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class SeparateClassLoaderTest { @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .jvmArgsAppend("-Djmh.separateClassLoader=true") .build(); new Runner(opts).run(); } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/000077500000000000000000000000001446271450100241015ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkBenchSharingTest.java000066400000000000000000000061331446271450100317550ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.sharing; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class BenchmarkBenchSharingTest { final Set visitors = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Trial) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(2, visitors.size()); } else { Assert.assertTrue(visitors.size() >= 2); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Fixtures.work(); visitors.add(Thread.currentThread()); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkStateSharingTest.java000066400000000000000000000062661446271450100320250ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.sharing; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; public class BenchmarkStateSharingTest { @State(Scope.Benchmark) public static class MyState { final Set visitors = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Trial) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(2, visitors.size()); } else { Assert.assertTrue(visitors.size() >= 2); } } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test(MyState s) { Fixtures.work(); s.visitors.add(Thread.currentThread()); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupBenchSharingTest.java000066400000000000000000000067231446271450100311640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.sharing; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @State(Scope.Group) public class GroupBenchSharingTest { final Set visitors = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Trial) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(4, visitors.size()); } else { Assert.assertTrue(visitors.size() >= 4); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("group1") @GroupThreads(2) public void test1() { Fixtures.work(); visitors.add(Thread.currentThread()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("group1") @GroupThreads(2) public void test2() { Fixtures.work(); visitors.add(Thread.currentThread()); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java000066400000000000000000000062361446271450100324700ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.sharing; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @State(Scope.Group) public class GroupDefaultBenchSharingTest { final Set visitors = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Trial) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(2, visitors.size()); } else { Assert.assertTrue(visitors.size() >= 2); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(2) public void test() { Fixtures.work(); visitors.add(Thread.currentThread()); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java000066400000000000000000000063711446271450100325310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.sharing; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; public class GroupDefaultStateSharingTest { @State(Scope.Group) public static class MyState { final Set visitors = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Trial) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(2, visitors.size()); } else { Assert.assertTrue(visitors.size() >= 2); } } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(2) public void test(MyState s) { Fixtures.work(); s.visitors.add(Thread.currentThread()); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupStateSharingTest.java000066400000000000000000000070541446271450100312230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.sharing; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; public class GroupStateSharingTest { @State(Scope.Group) public static class MyState { final Set visitors = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Trial) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(4, visitors.size()); } else { Assert.assertTrue(visitors.size() >= 4); } } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("group1") @GroupThreads(2) public void test1(MyState s) { Fixtures.work(); s.visitors.add(Thread.currentThread()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Group("group1") @GroupThreads(2) public void test2(MyState s) { Fixtures.work(); s.visitors.add(Thread.currentThread()); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadBenchSharingTest.java000066400000000000000000000061251446271450100312730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.sharing; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @State(Scope.Thread) public class ThreadBenchSharingTest { final Set visitors = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Trial) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(1, visitors.size()); } else { Assert.assertTrue(visitors.size() >= 1); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Fixtures.work(); visitors.add(Thread.currentThread()); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadStateSharingTest.java000066400000000000000000000062601446271450100313340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.sharing; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; public class ThreadStateSharingTest { @State(Scope.Thread) public static class MyState { final Set visitors = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Trial) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(1, visitors.size()); } else { Assert.assertTrue(visitors.size() >= 1); } } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test(MyState s) { Fixtures.work(); s.visitors.add(Thread.currentThread()); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/synciter/000077500000000000000000000000001446271450100243065ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/synciter/SyncIterMeasurementOnlyTest.java000066400000000000000000000055021446271450100326230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.synciter; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class SyncIterMeasurementOnlyTest { @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Assert.assertTrue(isInMeasurementLoop()); Fixtures.work(); } private boolean isInMeasurementLoop() { boolean inMeasurementLoop = false; for (StackTraceElement element : new Exception().getStackTrace()) { inMeasurementLoop |= element.getMethodName().contains("jmhStub"); } return inMeasurementLoop; } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(false) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/synciter/SyncIterNotOnlyMeasurementTest.java000066400000000000000000000071371446271450100333120ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.synciter; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Benchmark) public class SyncIterNotOnlyMeasurementTest { private boolean inMeasurementLoopOnly; @Setup(Level.Trial) public void setup() { inMeasurementLoopOnly = true; } @TearDown(Level.Trial) public void check() { Assert.assertFalse(inMeasurementLoopOnly); } @Benchmark @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { inMeasurementLoopOnly &= isInMeasurementLoop(); Fixtures.work(); } private boolean isInMeasurementLoop() { boolean inMeasurementLoop = false; for (StackTraceElement element : new Exception().getStackTrace()) { inMeasurementLoop |= element.getMethodName().contains("jmhStub"); } return inMeasurementLoop; } @Test public void invokeAPI() throws RunnerException { // This test is probabilistic, and it can fail sometimes, but not all the time. Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .syncIterations(true) .build(); final int trials = 200; RunnerException last = null; for (int c = 0; c < trials; c++) { try { new Runner(opt).run(); // no assert, yay, we can break away now return; } catch (RunnerException e) { last = e; } } // we consistently throw exceptions, re-throw the last one throw last; } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/000077500000000000000000000000001446271450100251215ustar00rootroot00000000000000GroupThreadParamsStabilityTest.java000066400000000000000000000053431446271450100340270ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threadparams; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.ThreadParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) @Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public class GroupThreadParamsStabilityTest { @State(Scope.Thread) public static class Data { ThreadParams last; void test(ThreadParams params) { if (last == null) { last = params; } else { // simple equality suffices Assert.assertEquals(last, params); } } } @Group("T") @Benchmark public void test1(ThreadParams tp, Data d) { d.test(tp); } @Group("T") @Benchmark public void test2(ThreadParams tp, Data d) { d.test(tp); } @Test public void test() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/ThreadParamsStabilityTest.java000066400000000000000000000051431446271450100330670ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threadparams; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.ThreadParams; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) @Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public class ThreadParamsStabilityTest { @State(Scope.Thread) public static class Data { ThreadParams last; void test(ThreadParams params) { if (last == null) { last = params; } else { // simple equality suffices Assert.assertEquals(last, params); } } } @Benchmark public void test1(ThreadParams tp, Data d) { d.test(tp); } @Test public void test() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/000077500000000000000000000000001446271450100241005ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/BenchmarkBenchSameThreadTest.java000066400000000000000000000122131446271450100323720ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; /** * Tests if harness executes setup, run, and tearDown in the same workers. */ @State(Scope.Benchmark) public class BenchmarkBenchSameThreadTest { private final Set setupRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set testInvocationThread = Collections.synchronizedSet(new HashSet<>()); @Setup(Level.Trial) public void setupRun() { setupRunThread.add(Thread.currentThread()); } @Setup(Level.Iteration) public void setupIteration() { setupIterationThread.add(Thread.currentThread()); } @Setup(Level.Invocation) public void setupInvocation() { setupInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void tearDownRun() { teardownRunThread.add(Thread.currentThread()); } @TearDown(Level.Iteration) public void tearDownIteration() { teardownIterationThread.add(Thread.currentThread()); } @TearDown(Level.Invocation) public void tearDownInvocation() { teardownInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void teardownZZZ() { // should perform last Assert.assertFalse("Test sanity", testInvocationThread.isEmpty()); Assert.assertTrue("test <: setupRun", testInvocationThread.containsAll(setupRunThread)); Assert.assertTrue("test <: setupIteration", testInvocationThread.containsAll(setupIterationThread)); Assert.assertTrue("test <: setupInvocation", testInvocationThread.containsAll(setupInvocationThread)); Assert.assertTrue("test <: teardownRun", testInvocationThread.containsAll(teardownRunThread)); Assert.assertTrue("test <: teardownIteration", testInvocationThread.containsAll(teardownIterationThread)); Assert.assertTrue("test <: teardownInvocation", testInvocationThread.containsAll(teardownInvocationThread)); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { testInvocationThread.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/BenchmarkStateSameThreadTest.java000066400000000000000000000125571446271450100324460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; /** * Tests if harness executes setup, run, and tearDown in the same workers. */ public class BenchmarkStateSameThreadTest { @State(Scope.Benchmark) public static class MyState { private final Set setupRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set testInvocationThread = Collections.synchronizedSet(new HashSet<>()); @Setup(Level.Trial) public void setupRun() { setupRunThread.add(Thread.currentThread()); } @Setup(Level.Iteration) public void setupIteration() { setupIterationThread.add(Thread.currentThread()); } @Setup(Level.Invocation) public void setupInvocation() { setupInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void tearDownRun() { teardownRunThread.add(Thread.currentThread()); } @TearDown(Level.Iteration) public void tearDownIteration() { teardownIterationThread.add(Thread.currentThread()); } @TearDown(Level.Invocation) public void tearDownInvocation() { teardownInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void teardownZZZ() { // should perform last Assert.assertFalse("Test sanity", testInvocationThread.isEmpty()); Assert.assertTrue("test <: setupRun", testInvocationThread.containsAll(setupRunThread)); Assert.assertTrue("test <: setupIteration", testInvocationThread.containsAll(setupIterationThread)); Assert.assertTrue("test <: setupInvocation", testInvocationThread.containsAll(setupInvocationThread)); Assert.assertTrue("test <: teardownRun", testInvocationThread.containsAll(teardownRunThread)); Assert.assertTrue("test <: teardownIteration", testInvocationThread.containsAll(teardownIterationThread)); Assert.assertTrue("test <: teardownInvocation", testInvocationThread.containsAll(teardownInvocationThread)); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test(MyState state) { state.testInvocationThread.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupBenchSameThreadTest.java000066400000000000000000000123071446271450100316000ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; /** * Tests if harness executes setup, run, and tearDown in the same workers. */ @State(Scope.Group) public class GroupBenchSameThreadTest { private final Set setupRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set testInvocationThread = Collections.synchronizedSet(new HashSet<>()); @Setup(Level.Trial) public void setupRun() { setupRunThread.add(Thread.currentThread()); } @Setup(Level.Iteration) public void setupIteration() { setupIterationThread.add(Thread.currentThread()); } @Setup(Level.Invocation) public void setupInvocation() { setupInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void tearDownRun() { teardownRunThread.add(Thread.currentThread()); } @TearDown(Level.Iteration) public void tearDownIteration() { teardownIterationThread.add(Thread.currentThread()); } @TearDown(Level.Invocation) public void tearDownInvocation() { teardownInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void teardownZZZ() { // should perform last Assert.assertFalse("Test sanity", testInvocationThread.isEmpty()); Assert.assertTrue("test <: setupRun", testInvocationThread.containsAll(setupRunThread)); Assert.assertTrue("test <: setupIteration", testInvocationThread.containsAll(setupIterationThread)); Assert.assertTrue("test <: setupInvocation", testInvocationThread.containsAll(setupInvocationThread)); Assert.assertTrue("test <: teardownRun", testInvocationThread.containsAll(teardownRunThread)); Assert.assertTrue("test <: teardownIteration", testInvocationThread.containsAll(teardownIterationThread)); Assert.assertTrue("test <: teardownInvocation", testInvocationThread.containsAll(teardownInvocationThread)); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(4) public void test() { testInvocationThread.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupStateSameThreadTest.java000066400000000000000000000126531446271450100316450ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; /** * Tests if harness executes setup, run, and tearDown in the same workers. */ public class GroupStateSameThreadTest { @State(Scope.Group) public static class MyState { private final Set setupRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set testInvocationThread = Collections.synchronizedSet(new HashSet<>()); @Setup(Level.Trial) public void setupRun() { setupRunThread.add(Thread.currentThread()); } @Setup(Level.Iteration) public void setupIteration() { setupIterationThread.add(Thread.currentThread()); } @Setup(Level.Invocation) public void setupInvocation() { setupInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void tearDownRun() { teardownRunThread.add(Thread.currentThread()); } @TearDown(Level.Iteration) public void tearDownIteration() { teardownIterationThread.add(Thread.currentThread()); } @TearDown(Level.Invocation) public void tearDownInvocation() { teardownInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void teardownZZZ() { // should perform last Assert.assertFalse("Test sanity", testInvocationThread.isEmpty()); Assert.assertTrue("test <: setupRun", testInvocationThread.containsAll(setupRunThread)); Assert.assertTrue("test <: setupIteration", testInvocationThread.containsAll(setupIterationThread)); Assert.assertTrue("test <: setupInvocation", testInvocationThread.containsAll(setupInvocationThread)); Assert.assertTrue("test <: teardownRun", testInvocationThread.containsAll(teardownRunThread)); Assert.assertTrue("test <: teardownIteration", testInvocationThread.containsAll(teardownIterationThread)); Assert.assertTrue("test <: teardownInvocation", testInvocationThread.containsAll(teardownInvocationThread)); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(4) public void test(MyState state) { state.testInvocationThread.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupThreadGroupOrderTest.java000066400000000000000000000064351446271450100320500ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; /** * Tests if harness executes setup, run, and tearDown in the same workers. */ @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Group) public class GroupThreadGroupOrderTest { private final Set abc = Collections.synchronizedSet(new HashSet<>()); private final Set def = Collections.synchronizedSet(new HashSet<>()); private final Set ghi = Collections.synchronizedSet(new HashSet<>()); @Setup(Level.Iteration) public void prepare() { abc.clear(); def.clear(); ghi.clear(); } @TearDown(Level.Iteration) public void verify() { Assert.assertEquals("Test abc", 3, abc.size()); Assert.assertEquals("Test def", 1, def.size()); Assert.assertEquals("Test ghi", 2, ghi.size()); } @Benchmark @Group("T") public void abc() { abc.add(Thread.currentThread()); Fixtures.work(); } @Benchmark @Group("T") public void ghi() { ghi.add(Thread.currentThread()); Fixtures.work(); } @Benchmark @Group("T") public void def() { def.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .threadGroups(3, 1, 2) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java000066400000000000000000000075301446271450100304760ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) @State(Scope.Benchmark) public class MaxThreadCountTest { private final Set threads = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Iteration) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(threads.size(), Runtime.getRuntime().availableProcessors()); } else { Assert.assertTrue(threads.size() >= Runtime.getRuntime().availableProcessors()); } } @Benchmark @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 0) @Fork(1) @Threads(Threads.MAX) public void test1() { threads.add(Thread.currentThread()); Fixtures.work(); } @Benchmark @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 0) @Fork(1) public void test2() { threads.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI_1() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".*test1") .shouldFailOnError(true) .build(); new Runner(opt).run(); } } @Test public void invokeAPI_2() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".*test2") .shouldFailOnError(true) .threads(Threads.MAX) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java000066400000000000000000000073631446271450100304760ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) @State(Scope.Benchmark) public class OneThreadCountTest { private final Set threads = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Iteration) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(1, threads.size()); } else { Assert.assertTrue(threads.size() >= 1); } } @Benchmark @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 0) @Fork(1) @Threads(1) public void test1() { threads.add(Thread.currentThread()); Fixtures.work(); } @Benchmark @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 0) @Fork(1) public void test2() { threads.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI_1() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".*test1") .shouldFailOnError(true) .build(); new Runner(opt).run(); } } @Test public void invokeAPI_2() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".*test2") .shouldFailOnError(true) .threads(1) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/ThreadBenchSameThreadTest.java000066400000000000000000000125211446271450100317110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; /** * Tests if harness executes setup, run, and tearDown in the same workers. */ @State(Scope.Thread) public class ThreadBenchSameThreadTest { private final Set setupRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set testInvocationThread = Collections.synchronizedSet(new HashSet<>()); @Setup(Level.Trial) public void setupRun() { setupRunThread.add(Thread.currentThread()); } @Setup(Level.Iteration) public void setupIteration() { setupIterationThread.add(Thread.currentThread()); } @Setup(Level.Invocation) public void setupInvocation() { setupInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void tearDownRun() { teardownRunThread.add(Thread.currentThread()); // Threads can change iteration to iteration if (Fixtures.expectStableThreads()) { Assert.assertEquals("test == setupRun", testInvocationThread, setupRunThread); Assert.assertEquals("test == teardownRun", testInvocationThread, teardownRunThread); } else { Assert.assertTrue("test <: setupRun", testInvocationThread.containsAll(setupRunThread)); Assert.assertTrue("test <: teardownRunThread", testInvocationThread.containsAll(teardownRunThread)); } } @TearDown(Level.Iteration) public void tearDownIteration() { teardownIterationThread.add(Thread.currentThread()); // Within iteration, expect the same thread Assert.assertEquals("test == setupIteration", testInvocationThread, setupIterationThread); Assert.assertEquals("test == teardownIteration", testInvocationThread, teardownIterationThread); Assert.assertEquals("test == setupInvocation", testInvocationThread, setupInvocationThread); Assert.assertEquals("test == teardownInvocation", testInvocationThread, teardownInvocationThread); } @TearDown(Level.Invocation) public void tearDownInvocation() { teardownInvocationThread.add(Thread.currentThread()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test() { testInvocationThread.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/ThreadStateSameThreadTest.java000066400000000000000000000131011446271450100317450ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; /** * Tests if harness executes setup, run, and tearDown in the same workers. */ public class ThreadStateSameThreadTest { @State(Scope.Thread) public static class MyState { private final Set setupRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownRunThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet<>()); private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet<>()); private final Set testInvocationThread = Collections.synchronizedSet(new HashSet<>()); @Setup(Level.Trial) public void setupRun() { setupRunThread.add(Thread.currentThread()); } @Setup(Level.Iteration) public void setupIteration() { setupIterationThread.add(Thread.currentThread()); } @Setup(Level.Invocation) public void setupInvocation() { setupInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void tearDownRun() { teardownRunThread.add(Thread.currentThread()); // Threads can change iteration to iteration if (Fixtures.expectStableThreads()) { Assert.assertEquals("test == setupRun", testInvocationThread, setupRunThread); Assert.assertEquals("test == teardownRun", testInvocationThread, teardownRunThread); } else { Assert.assertTrue("test <: setupRun", testInvocationThread.containsAll(setupRunThread)); Assert.assertTrue("test <: teardownRunThread", testInvocationThread.containsAll(teardownRunThread)); } } @TearDown(Level.Iteration) public void tearDownIteration() { teardownIterationThread.add(Thread.currentThread()); // Within iteration, expect the same thread Assert.assertEquals("test == setupIteration", testInvocationThread, setupIterationThread); Assert.assertEquals("test == teardownIteration", testInvocationThread, teardownIterationThread); Assert.assertEquals("test == setupInvocation", testInvocationThread, setupInvocationThread); Assert.assertEquals("test == teardownInvocation", testInvocationThread, teardownInvocationThread); } @TearDown(Level.Invocation) public void tearDownInvocation() { teardownInvocationThread.add(Thread.currentThread()); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(4) public void test(MyState state) { state.testInvocationThread.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java000066400000000000000000000073631446271450100305260ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.threads; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.All) @State(Scope.Benchmark) public class TwoThreadCountTest { private final Set threads = Collections.synchronizedSet(new HashSet<>()); @TearDown(Level.Iteration) public void tearDown() { if (Fixtures.expectStableThreads()) { Assert.assertEquals(2, threads.size()); } else { Assert.assertTrue(threads.size() >= 2); } } @Benchmark @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 0) @Fork(1) @Threads(2) public void test1() { threads.add(Thread.currentThread()); Fixtures.work(); } @Benchmark @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Warmup(iterations = 0) @Fork(1) public void test2() { threads.add(Thread.currentThread()); Fixtures.work(); } @Test public void invokeAPI_1() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".*test1") .shouldFailOnError(true) .build(); new Runner(opt).run(); } } @Test public void invokeAPI_2() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass()) + ".*test2") .shouldFailOnError(true) .threads(2) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/000077500000000000000000000000001446271450100235675ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/BenchmarkBenchHelperTimesTest.java000066400000000000000000000145561446271450100323010ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Benchmark) public class BenchmarkBenchHelperTimesTest { private final AtomicInteger countInvocations = new AtomicInteger(); private final AtomicInteger countSetupRun1 = new AtomicInteger(); private final AtomicInteger countSetupRun2 = new AtomicInteger(); private final AtomicInteger countSetupIteration1 = new AtomicInteger(); private final AtomicInteger countSetupIteration2 = new AtomicInteger(); private final AtomicInteger countSetupInvocation1 = new AtomicInteger(); private final AtomicInteger countSetupInvocation2 = new AtomicInteger(); private final AtomicInteger countTearDownRun1 = new AtomicInteger(); private final AtomicInteger countTearDownRun2 = new AtomicInteger(); private final AtomicInteger countTearDownIteration1 = new AtomicInteger(); private final AtomicInteger countTearDownIteration2 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation1 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation2 = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun1.incrementAndGet(); } @Setup(Level.Trial) public void setup2() { countSetupRun2.incrementAndGet(); } @Setup(Level.Iteration) public void setup3() { countSetupIteration1.incrementAndGet(); } @Setup(Level.Iteration) public void setup4() { countSetupIteration2.incrementAndGet(); } @Setup(Level.Invocation) public void setup5() { countSetupInvocation1.incrementAndGet(); } @Setup(Level.Invocation) public void setup6() { countSetupInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun1.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown2() { countTearDownRun2.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown3() { countTearDownIteration1.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown4() { countTearDownIteration2.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown5() { countTearDownInvocation1.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown6() { countTearDownInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun1.get()); Assert.assertEquals("Setup2 called once", 1, countSetupRun2.get()); Assert.assertEquals("Setup3 called twice", 2, countSetupIteration1.get()); Assert.assertEquals("Setup4 called twice", 2, countSetupIteration2.get()); // These asserts make no sense for Benchmark tests // Assert.assertEquals("Setup5 = invocation count", countInvocations.get(), countSetupInvocation1.get()); // Assert.assertEquals("Setup6 = invocation count", countInvocations.get(), countSetupInvocation2.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun1.get()); Assert.assertEquals("TearDown2 called once", 1, countTearDownRun2.get()); Assert.assertEquals("TearDown3 called twice", 2, countTearDownIteration1.get()); Assert.assertEquals("TearDown4 called twice", 2, countTearDownIteration2.get()); // These two asserts make no sense for Benchmark tests. // Assert.assertEquals("TearDown5 = invocation count", countInvocations.get(), countTearDownInvocation1.get()); // Assert.assertEquals("TearDown6 = invocation count", countInvocations.get(), countTearDownInvocation2.get()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Fixtures.work(); countInvocations.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/BenchmarkStateHelperTimesTest.java000066400000000000000000000154241446271450100323350ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class BenchmarkStateHelperTimesTest { @State(Scope.Benchmark) public static class MyState { private final AtomicInteger countInvocations = new AtomicInteger(); private final AtomicInteger countSetupRun1 = new AtomicInteger(); private final AtomicInteger countSetupRun2 = new AtomicInteger(); private final AtomicInteger countSetupIteration1 = new AtomicInteger(); private final AtomicInteger countSetupIteration2 = new AtomicInteger(); private final AtomicInteger countSetupInvocation1 = new AtomicInteger(); private final AtomicInteger countSetupInvocation2 = new AtomicInteger(); private final AtomicInteger countTearDownRun1 = new AtomicInteger(); private final AtomicInteger countTearDownRun2 = new AtomicInteger(); private final AtomicInteger countTearDownIteration1 = new AtomicInteger(); private final AtomicInteger countTearDownIteration2 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation1 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation2 = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun1.incrementAndGet(); } @Setup(Level.Trial) public void setup2() { countSetupRun2.incrementAndGet(); } @Setup(Level.Iteration) public void setup3() { countSetupIteration1.incrementAndGet(); } @Setup(Level.Iteration) public void setup4() { countSetupIteration2.incrementAndGet(); } @Setup(Level.Invocation) public void setup5() { countSetupInvocation1.incrementAndGet(); } @Setup(Level.Invocation) public void setup6() { countSetupInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun1.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown2() { countTearDownRun2.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown3() { countTearDownIteration1.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown4() { countTearDownIteration2.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown5() { countTearDownInvocation1.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown6() { countTearDownInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun1.get()); Assert.assertEquals("Setup2 called once", 1, countSetupRun2.get()); Assert.assertEquals("Setup3 called twice", 2, countSetupIteration1.get()); Assert.assertEquals("Setup4 called twice", 2, countSetupIteration2.get()); // These asserts make no sense for Benchmark tests // Assert.assertEquals("Setup5 = invocation count", countInvocations.get(), countSetupInvocation1.get()); // Assert.assertEquals("Setup6 = invocation count", countInvocations.get(), countSetupInvocation2.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun1.get()); Assert.assertEquals("TearDown2 called once", 1, countTearDownRun2.get()); Assert.assertEquals("TearDown3 called twice", 2, countTearDownIteration1.get()); Assert.assertEquals("TearDown4 called twice", 2, countTearDownIteration2.get()); // These two asserts make no sense for Benchmark tests. // Assert.assertEquals("TearDown5 = invocation count", countInvocations.get(), countTearDownInvocation1.get()); // Assert.assertEquals("TearDown6 = invocation count", countInvocations.get(), countTearDownInvocation2.get()); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test(MyState state) { Fixtures.work(); state.countInvocations.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupBenchHelperTimesTest.java000066400000000000000000000147271446271450100315030ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Group) public class GroupBenchHelperTimesTest { private final AtomicInteger countInvocations = new AtomicInteger(); private final AtomicInteger countSetupRun1 = new AtomicInteger(); private final AtomicInteger countSetupRun2 = new AtomicInteger(); private final AtomicInteger countSetupIteration1 = new AtomicInteger(); private final AtomicInteger countSetupIteration2 = new AtomicInteger(); private final AtomicInteger countSetupInvocation1 = new AtomicInteger(); private final AtomicInteger countSetupInvocation2 = new AtomicInteger(); private final AtomicInteger countTearDownRun1 = new AtomicInteger(); private final AtomicInteger countTearDownRun2 = new AtomicInteger(); private final AtomicInteger countTearDownIteration1 = new AtomicInteger(); private final AtomicInteger countTearDownIteration2 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation1 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation2 = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun1.incrementAndGet(); } @Setup(Level.Trial) public void setup2() { countSetupRun2.incrementAndGet(); } @Setup(Level.Iteration) public void setup3() { countSetupIteration1.incrementAndGet(); } @Setup(Level.Iteration) public void setup4() { countSetupIteration2.incrementAndGet(); } @Setup(Level.Invocation) public void setup5() { countSetupInvocation1.incrementAndGet(); } @Setup(Level.Invocation) public void setup6() { countSetupInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun1.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown2() { countTearDownRun2.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown3() { countTearDownIteration1.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown4() { countTearDownIteration2.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown5() { countTearDownInvocation1.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown6() { countTearDownInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun1.get()); Assert.assertEquals("Setup2 called once", 1, countSetupRun2.get()); Assert.assertEquals("Setup3 called twice", 2, countSetupIteration1.get()); Assert.assertEquals("Setup4 called twice", 2, countSetupIteration2.get()); // These asserts make no sense for Benchmark tests // Assert.assertEquals("Setup5 = invocation count", countInvocations.get(), countSetupInvocation1.get()); // Assert.assertEquals("Setup6 = invocation count", countInvocations.get(), countSetupInvocation2.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun1.get()); Assert.assertEquals("TearDown2 called once", 1, countTearDownRun2.get()); Assert.assertEquals("TearDown3 called twice", 2, countTearDownIteration1.get()); Assert.assertEquals("TearDown4 called twice", 2, countTearDownIteration2.get()); // These two asserts make no sense for Benchmark tests. // Assert.assertEquals("TearDown5 = invocation count", countInvocations.get(), countTearDownInvocation1.get()); // Assert.assertEquals("TearDown6 = invocation count", countInvocations.get(), countTearDownInvocation2.get()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(2) public void test() { Fixtures.work(); countInvocations.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupStateHelperTimesTest.java000066400000000000000000000155201446271450100315340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class GroupStateHelperTimesTest { @State(Scope.Group) public static class MyState { private final AtomicInteger countInvocations = new AtomicInteger(); private final AtomicInteger countSetupRun1 = new AtomicInteger(); private final AtomicInteger countSetupRun2 = new AtomicInteger(); private final AtomicInteger countSetupIteration1 = new AtomicInteger(); private final AtomicInteger countSetupIteration2 = new AtomicInteger(); private final AtomicInteger countSetupInvocation1 = new AtomicInteger(); private final AtomicInteger countSetupInvocation2 = new AtomicInteger(); private final AtomicInteger countTearDownRun1 = new AtomicInteger(); private final AtomicInteger countTearDownRun2 = new AtomicInteger(); private final AtomicInteger countTearDownIteration1 = new AtomicInteger(); private final AtomicInteger countTearDownIteration2 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation1 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation2 = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun1.incrementAndGet(); } @Setup(Level.Trial) public void setup2() { countSetupRun2.incrementAndGet(); } @Setup(Level.Iteration) public void setup3() { countSetupIteration1.incrementAndGet(); } @Setup(Level.Iteration) public void setup4() { countSetupIteration2.incrementAndGet(); } @Setup(Level.Invocation) public void setup5() { countSetupInvocation1.incrementAndGet(); } @Setup(Level.Invocation) public void setup6() { countSetupInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun1.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown2() { countTearDownRun2.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown3() { countTearDownIteration1.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown4() { countTearDownIteration2.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown5() { countTearDownInvocation1.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown6() { countTearDownInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun1.get()); Assert.assertEquals("Setup2 called once", 1, countSetupRun2.get()); Assert.assertEquals("Setup3 called twice", 2, countSetupIteration1.get()); Assert.assertEquals("Setup4 called twice", 2, countSetupIteration2.get()); // These asserts make no sense for Benchmark tests // Assert.assertEquals("Setup5 = invocation count", countInvocations.get(), countSetupInvocation1.get()); // Assert.assertEquals("Setup6 = invocation count", countInvocations.get(), countSetupInvocation2.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun1.get()); Assert.assertEquals("TearDown2 called once", 1, countTearDownRun2.get()); Assert.assertEquals("TearDown3 called twice", 2, countTearDownIteration1.get()); Assert.assertEquals("TearDown4 called twice", 2, countTearDownIteration2.get()); // These two asserts make no sense for Benchmark tests. // Assert.assertEquals("TearDown5 = invocation count", countInvocations.get(), countTearDownInvocation1.get()); // Assert.assertEquals("TearDown6 = invocation count", countInvocations.get(), countTearDownInvocation2.get()); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(2) public void test(MyState state) { Fixtures.work(); state.countInvocations.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupThreadStateHelperTimesTest.java000066400000000000000000000073771446271450100326770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Tests if harness executes setup, run, and tearDown in the same workers. */ @BenchmarkMode(Mode.All) @Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @State(Scope.Benchmark) public class GroupThreadStateHelperTimesTest { @State(Scope.Thread) public static class State1 { static final AtomicInteger setupTimes = new AtomicInteger(); static final AtomicInteger tearDownTimes = new AtomicInteger(); @Setup public void setup() { setupTimes.incrementAndGet(); } @Setup public void tearDown() { tearDownTimes.incrementAndGet(); } } @State(Scope.Thread) public static class State2 { static final AtomicInteger setupTimes = new AtomicInteger(); static final AtomicInteger tearDownTimes = new AtomicInteger(); @Setup public void setup() { setupTimes.incrementAndGet(); } @Setup public void tearDown() { tearDownTimes.incrementAndGet(); } } @Setup public void reset() { State1.setupTimes.set(0); State1.tearDownTimes.set(0); State2.setupTimes.set(0); State2.tearDownTimes.set(0); } @TearDown public void verify() { Assert.assertEquals(1, State1.setupTimes.get()); Assert.assertEquals(1, State1.tearDownTimes.get()); Assert.assertEquals(1, State2.setupTimes.get()); Assert.assertEquals(1, State2.tearDownTimes.get()); } @Benchmark @Group("T") public void test1(State1 state1) { Fixtures.work(); } @Benchmark @Group("T") public void test2(State2 state2) { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/ThreadBenchHelperTimesTest.java000066400000000000000000000144201446271450100316040ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Thread) public class ThreadBenchHelperTimesTest { private final AtomicInteger countInvocations = new AtomicInteger(); private final AtomicInteger countSetupRun1 = new AtomicInteger(); private final AtomicInteger countSetupRun2 = new AtomicInteger(); private final AtomicInteger countSetupIteration1 = new AtomicInteger(); private final AtomicInteger countSetupIteration2 = new AtomicInteger(); private final AtomicInteger countSetupInvocation1 = new AtomicInteger(); private final AtomicInteger countSetupInvocation2 = new AtomicInteger(); private final AtomicInteger countTearDownRun1 = new AtomicInteger(); private final AtomicInteger countTearDownRun2 = new AtomicInteger(); private final AtomicInteger countTearDownIteration1 = new AtomicInteger(); private final AtomicInteger countTearDownIteration2 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation1 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation2 = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun1.incrementAndGet(); } @Setup(Level.Trial) public void setup2() { countSetupRun2.incrementAndGet(); } @Setup(Level.Iteration) public void setup3() { countSetupIteration1.incrementAndGet(); } @Setup(Level.Iteration) public void setup4() { countSetupIteration2.incrementAndGet(); } @Setup(Level.Invocation) public void setup5() { countSetupInvocation1.incrementAndGet(); } @Setup(Level.Invocation) public void setup6() { countSetupInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun1.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown2() { countTearDownRun2.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown3() { countTearDownIteration1.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown4() { countTearDownIteration2.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown5() { countTearDownInvocation1.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown6() { countTearDownInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun1.get()); Assert.assertEquals("Setup2 called once", 1, countSetupRun2.get()); Assert.assertEquals("Setup3 called twice", 2, countSetupIteration1.get()); Assert.assertEquals("Setup4 called twice", 2, countSetupIteration2.get()); Assert.assertEquals("Setup5 = invocation count", countInvocations.get(), countSetupInvocation1.get()); Assert.assertEquals("Setup6 = invocation count", countInvocations.get(), countSetupInvocation2.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun1.get()); Assert.assertEquals("TearDown2 called once", 1, countTearDownRun2.get()); Assert.assertEquals("TearDown3 called twice", 2, countTearDownIteration1.get()); Assert.assertEquals("TearDown4 called twice", 2, countTearDownIteration2.get()); Assert.assertEquals("TearDown5 = invocation count", countInvocations.get(), countTearDownInvocation1.get()); Assert.assertEquals("TearDown6 = invocation count", countInvocations.get(), countTearDownInvocation2.get()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Fixtures.work(); countInvocations.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/ThreadStateHelperTimesTest.java000066400000000000000000000152011446271450100316430ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class ThreadStateHelperTimesTest { @State(Scope.Thread) public static class MyState { private final AtomicInteger countInvocations = new AtomicInteger(); private final AtomicInteger countSetupRun1 = new AtomicInteger(); private final AtomicInteger countSetupRun2 = new AtomicInteger(); private final AtomicInteger countSetupIteration1 = new AtomicInteger(); private final AtomicInteger countSetupIteration2 = new AtomicInteger(); private final AtomicInteger countSetupInvocation1 = new AtomicInteger(); private final AtomicInteger countSetupInvocation2 = new AtomicInteger(); private final AtomicInteger countTearDownRun1 = new AtomicInteger(); private final AtomicInteger countTearDownRun2 = new AtomicInteger(); private final AtomicInteger countTearDownIteration1 = new AtomicInteger(); private final AtomicInteger countTearDownIteration2 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation1 = new AtomicInteger(); private final AtomicInteger countTearDownInvocation2 = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun1.incrementAndGet(); } @Setup(Level.Trial) public void setup2() { countSetupRun2.incrementAndGet(); } @Setup(Level.Iteration) public void setup3() { countSetupIteration1.incrementAndGet(); } @Setup(Level.Iteration) public void setup4() { countSetupIteration2.incrementAndGet(); } @Setup(Level.Invocation) public void setup5() { countSetupInvocation1.incrementAndGet(); } @Setup(Level.Invocation) public void setup6() { countSetupInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun1.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown2() { countTearDownRun2.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown3() { countTearDownIteration1.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown4() { countTearDownIteration2.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown5() { countTearDownInvocation1.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown6() { countTearDownInvocation2.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun1.get()); Assert.assertEquals("Setup2 called once", 1, countSetupRun2.get()); Assert.assertEquals("Setup3 called twice", 2, countSetupIteration1.get()); Assert.assertEquals("Setup4 called twice", 2, countSetupIteration2.get()); Assert.assertEquals("Setup5 = invocation count", countInvocations.get(), countSetupInvocation1.get()); Assert.assertEquals("Setup6 = invocation count", countInvocations.get(), countSetupInvocation2.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun1.get()); Assert.assertEquals("TearDown2 called once", 1, countTearDownRun2.get()); Assert.assertEquals("TearDown3 called twice", 2, countTearDownIteration1.get()); Assert.assertEquals("TearDown4 called twice", 2, countTearDownIteration2.get()); Assert.assertEquals("TearDown5 = invocation count", countInvocations.get(), countTearDownInvocation1.get()); Assert.assertEquals("TearDown6 = invocation count", countInvocations.get(), countTearDownInvocation2.get()); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test(MyState state) { Fixtures.work(); state.countInvocations.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/batches/000077500000000000000000000000001446271450100252005ustar00rootroot00000000000000BenchmarkBatchedBenchHelperTimesTest.java000066400000000000000000000114601446271450100350750ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/batches/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.batches; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Benchmark) public class BenchmarkBatchedBenchHelperTimesTest { private final AtomicInteger countInvocations = new AtomicInteger(); private final AtomicInteger countSetupRun = new AtomicInteger(); private final AtomicInteger countSetupIteration = new AtomicInteger(); private final AtomicInteger countSetupInvocation = new AtomicInteger(); private final AtomicInteger countTearDownRun = new AtomicInteger(); private final AtomicInteger countTearDownIteration = new AtomicInteger(); private final AtomicInteger countTearDownInvocation = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun.incrementAndGet(); } @Setup(Level.Iteration) public void setup2() { countSetupIteration.incrementAndGet(); } @Setup(Level.Invocation) public void setup3() { countSetupInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown2() { countTearDownIteration.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown3() { countTearDownInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun.get()); Assert.assertEquals("Setup2 called twice", 2, countSetupIteration.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun.get()); Assert.assertEquals("TearDown2 called twice", 2, countTearDownIteration.get()); Assert.assertEquals("Setup3 and TearDown3 agree", countSetupInvocation.get(), countTearDownInvocation.get()); Assert.assertEquals("Test invocations and Setup3 agree", countInvocations.get(), countSetupInvocation.get()); Assert.assertEquals("Test invocations and TearDown3 agree", countInvocations.get(), countTearDownInvocation.get()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Fixtures.work(); countInvocations.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .warmupBatchSize(10) .measurementBatchSize(10) .build(); new Runner(opt).run(); } } } GroupBatchedBenchHelperTimesTest.java000066400000000000000000000115541446271450100343030ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/batches/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.batches; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Group) public class GroupBatchedBenchHelperTimesTest { private final AtomicInteger countInvocations = new AtomicInteger(); private final AtomicInteger countSetupRun = new AtomicInteger(); private final AtomicInteger countSetupIteration = new AtomicInteger(); private final AtomicInteger countSetupInvocation = new AtomicInteger(); private final AtomicInteger countTearDownRun = new AtomicInteger(); private final AtomicInteger countTearDownIteration = new AtomicInteger(); private final AtomicInteger countTearDownInvocation = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun.incrementAndGet(); } @Setup(Level.Iteration) public void setup2() { countSetupIteration.incrementAndGet(); } @Setup(Level.Invocation) public void setup3() { countSetupInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown2() { countTearDownIteration.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown3() { countTearDownInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun.get()); Assert.assertEquals("Setup2 called twice", 2, countSetupIteration.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun.get()); Assert.assertEquals("TearDown2 called twice", 2, countTearDownIteration.get()); Assert.assertEquals("Setup3 and TearDown3 agree", countSetupInvocation.get(), countTearDownInvocation.get()); Assert.assertEquals("Test invocations and Setup3 agree", countInvocations.get(), countSetupInvocation.get()); Assert.assertEquals("Test invocations and TearDown3 agree", countInvocations.get(), countTearDownInvocation.get()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(2) public void test() { Fixtures.work(); countInvocations.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .warmupBatchSize(10) .measurementBatchSize(10) .build(); new Runner(opt).run(); } } } ThreadBatchedBenchHelperTimesTest.java000066400000000000000000000114521446271450100344130ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/batches/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.batches; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Thread) public class ThreadBatchedBenchHelperTimesTest { private final AtomicInteger countInvocations = new AtomicInteger(); private final AtomicInteger countSetupRun = new AtomicInteger(); private final AtomicInteger countSetupIteration = new AtomicInteger(); private final AtomicInteger countSetupInvocation = new AtomicInteger(); private final AtomicInteger countTearDownRun = new AtomicInteger(); private final AtomicInteger countTearDownIteration = new AtomicInteger(); private final AtomicInteger countTearDownInvocation = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun.incrementAndGet(); } @Setup(Level.Iteration) public void setup2() { countSetupIteration.incrementAndGet(); } @Setup(Level.Invocation) public void setup3() { countSetupInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown2() { countTearDownIteration.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown3() { countTearDownInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun.get()); Assert.assertEquals("Setup2 called twice", 2, countSetupIteration.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun.get()); Assert.assertEquals("TearDown2 called twice", 2, countTearDownIteration.get()); Assert.assertEquals("Setup3 and TearDown3 agree", countSetupInvocation.get(), countTearDownInvocation.get()); Assert.assertEquals("Test invocations and Setup3 agree", countInvocations.get(), countSetupInvocation.get()); Assert.assertEquals("Test invocations and TearDown3 agree", countInvocations.get(), countTearDownInvocation.get()); } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test() { Fixtures.work(); countInvocations.incrementAndGet(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .warmupBatchSize(10) .measurementBatchSize(10) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/000077500000000000000000000000001446271450100245025ustar00rootroot00000000000000BenchmarkInvocationFailureTimesTest.java000066400000000000000000000050561446271450100343720ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.fail; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Benchmark) public class BenchmarkInvocationFailureTimesTest { private static final AtomicInteger count = new AtomicInteger(); @Setup(Level.Invocation) public void setup() { count.incrementAndGet(); throw new IllegalStateException("Failing"); } @Benchmark public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; count.set(0); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .threads(Threads.MAX) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(1, count.get()); } } } } BenchmarkIterationFailureTimesTest.java000066400000000000000000000050541446271450100342150ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.fail; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Benchmark) public class BenchmarkIterationFailureTimesTest { private static final AtomicInteger count = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { count.incrementAndGet(); throw new IllegalStateException("Failing"); } @Benchmark public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; count.set(0); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .threads(Threads.MAX) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(1, count.get()); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkTrialFailureTimesTest.java000066400000000000000000000050441446271450100334100ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.fail; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Benchmark) public class BenchmarkTrialFailureTimesTest { private static final AtomicInteger count = new AtomicInteger(); @Setup(Level.Trial) public void setup() { count.incrementAndGet(); throw new IllegalStateException("Failing"); } @Benchmark public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; count.set(0); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .threads(Threads.MAX) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(1, count.get()); } } } } GroupInvocationFailureTimesTest.java000066400000000000000000000051501446271450100335670ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.fail; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Group) public class GroupInvocationFailureTimesTest { private static final AtomicInteger count = new AtomicInteger(); @Setup(Level.Invocation) public void setup() { count.incrementAndGet(); throw new IllegalStateException("Failing"); } @Benchmark @Group @GroupThreads(4) // should match the total number of threads public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; count.set(0); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .threads(4) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(1, count.get()); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupIterationFailureTimesTest.java000066400000000000000000000052451446271450100335000ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.fail; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Group) public class GroupIterationFailureTimesTest { private static final AtomicInteger count = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { System.err.println("Enter " + Thread.currentThread()); count.incrementAndGet(); throw new IllegalStateException("Failing"); } @Benchmark @Group @GroupThreads(4) // should match the total number of threads public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; count.set(0); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .threads(4) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(1, count.get()); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupTrialFailureTimesTest.java000066400000000000000000000050471446271450100326150ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.fail; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Group) public class GroupTrialFailureTimesTest { private static final AtomicInteger count = new AtomicInteger(); @Setup(Level.Trial) public void setup() { count.incrementAndGet(); throw new IllegalStateException("Failing"); } @Benchmark @Group public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; count.set(0); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .threads(Threads.MAX) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(1, count.get()); } } } } ThreadInvocationFailureTimesTest.java000066400000000000000000000050361446271450100337050ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.fail; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Thread) public class ThreadInvocationFailureTimesTest { private static final AtomicInteger count = new AtomicInteger(); @Setup(Level.Invocation) public void setup() { count.incrementAndGet(); throw new IllegalStateException("Failing"); } @Benchmark public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; count.set(0); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .threads(1) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(1, count.get()); } } } } ThreadIterationFailureTimesTest.java000066400000000000000000000050341446271450100335300ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.fail; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Thread) public class ThreadIterationFailureTimesTest { private static final AtomicInteger count = new AtomicInteger(); @Setup(Level.Iteration) public void setup() { count.incrementAndGet(); throw new IllegalStateException("Failing"); } @Benchmark public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; count.set(0); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .threads(1) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(1, count.get()); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadTrialFailureTimesTest.java000066400000000000000000000050241446271450100327230ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.fail; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Thread) public class ThreadTrialFailureTimesTest { private static final AtomicInteger count = new AtomicInteger(); @Setup(Level.Trial) public void setup() { count.incrementAndGet(); throw new IllegalStateException("Failing"); } @Benchmark public void test() { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; count.set(0); Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .threads(1) .forks(0) .build(); new Runner(opt).run(); Assert.assertEquals(1, count.get()); } } } } jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/statemerge/000077500000000000000000000000001446271450100257275ustar00rootroot00000000000000BenchmarkStateMergeHelperTimesTest.java000066400000000000000000000112141446271450100353670ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/statemerge/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.statemerge; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class BenchmarkStateMergeHelperTimesTest { @State(Scope.Benchmark) public static class MyState { private final AtomicInteger countSetupRun = new AtomicInteger(); private final AtomicInteger countSetupIteration = new AtomicInteger(); private final AtomicInteger countSetupInvocation = new AtomicInteger(); private final AtomicInteger countTearDownRun = new AtomicInteger(); private final AtomicInteger countTearDownIteration = new AtomicInteger(); private final AtomicInteger countTearDownInvocation = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun.incrementAndGet(); } @Setup(Level.Iteration) public void setup2() { countSetupIteration.incrementAndGet(); } @Setup(Level.Invocation) public void setup3() { countSetupInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown2() { countTearDownIteration.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown3() { countTearDownInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun.get()); Assert.assertEquals("Setup2 called twice", 2, countSetupIteration.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun.get()); Assert.assertEquals("TearDown2 called twice", 2, countTearDownIteration.get()); Assert.assertEquals("Setup3 and TearDown3 counters match", countSetupInvocation.get(), countTearDownInvocation.get()); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test(MyState state1, MyState state2) { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } GroupStateMergeHelperTimesTest.java000066400000000000000000000113101446271450100345660ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/statemerge/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.statemerge; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class GroupStateMergeHelperTimesTest { @State(Scope.Group) public static class MyState { private final AtomicInteger countSetupRun = new AtomicInteger(); private final AtomicInteger countSetupIteration = new AtomicInteger(); private final AtomicInteger countSetupInvocation = new AtomicInteger(); private final AtomicInteger countTearDownRun = new AtomicInteger(); private final AtomicInteger countTearDownIteration = new AtomicInteger(); private final AtomicInteger countTearDownInvocation = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun.incrementAndGet(); } @Setup(Level.Iteration) public void setup2() { countSetupIteration.incrementAndGet(); } @Setup(Level.Invocation) public void setup3() { countSetupInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown2() { countTearDownIteration.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown3() { countTearDownInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun.get()); Assert.assertEquals("Setup2 called twice", 2, countSetupIteration.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun.get()); Assert.assertEquals("TearDown2 called twice", 2, countTearDownIteration.get()); Assert.assertEquals("Setup3 and TearDown3 counters match", countSetupInvocation.get(), countTearDownInvocation.get()); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Group("T") @GroupThreads(2) public void test(MyState state1, MyState state2) { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } ThreadStateMergeHelperTimesTest.java000066400000000000000000000112061446271450100347050ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/statemerge/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.it.times.statemerge; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class ThreadStateMergeHelperTimesTest { @State(Scope.Thread) public static class MyState { private final AtomicInteger countSetupRun = new AtomicInteger(); private final AtomicInteger countSetupIteration = new AtomicInteger(); private final AtomicInteger countSetupInvocation = new AtomicInteger(); private final AtomicInteger countTearDownRun = new AtomicInteger(); private final AtomicInteger countTearDownIteration = new AtomicInteger(); private final AtomicInteger countTearDownInvocation = new AtomicInteger(); @Setup(Level.Trial) public void setup1() { countSetupRun.incrementAndGet(); } @Setup(Level.Iteration) public void setup2() { countSetupIteration.incrementAndGet(); } @Setup(Level.Invocation) public void setup3() { countSetupInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDown1() { countTearDownRun.incrementAndGet(); } @TearDown(Level.Iteration) public void tearDown2() { countTearDownIteration.incrementAndGet(); } @TearDown(Level.Invocation) public void tearDown3() { countTearDownInvocation.incrementAndGet(); } @TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun.get()); Assert.assertEquals("Setup2 called twice", 2, countSetupIteration.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun.get()); Assert.assertEquals("TearDown2 called twice", 2, countTearDownIteration.get()); Assert.assertEquals("Setup3 and TearDown3 counters match", countSetupInvocation.get(), countTearDownInvocation.get()); } } @Benchmark @BenchmarkMode(Mode.All) @Warmup(iterations = 0) @Measurement(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) @Threads(2) public void test(MyState state1, MyState state2) { Fixtures.work(); } @Test public void invokeAPI() throws RunnerException { for (int c = 0; c < Fixtures.repetitionCount(); c++) { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) .build(); new Runner(opt).run(); } } } jmh-1.37/jmh-core-it/src/test/resources/000077500000000000000000000000001446271450100201245ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/resources/LICENSE000066400000000000000000000455121446271450100211400ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-core-it/src/test/resources/META-INF/000077500000000000000000000000001446271450100212645ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/resources/META-INF/services/000077500000000000000000000000001446271450100231075ustar00rootroot00000000000000jmh-1.37/jmh-core-it/src/test/resources/META-INF/services/javax.annotation.processing.Processor000066400000000000000000000027331446271450100324520ustar00rootroot00000000000000# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. # # The order of these two processors is important: we want the JMH's processor # to fire first, and then see if it claims all JMH annotations, and nothing else. org.openjdk.jmh.generators.BenchmarkProcessor org.openjdk.jmh.it.annsteal.CustomBenchmarkProcessorjmh-1.37/jmh-core-it/src/test/resources/META-INF/services/org.openjdk.jmh.profile.Profiler000066400000000000000000000007301446271450100312470ustar00rootroot00000000000000org.openjdk.jmh.it.profilers.ItInternalProfiler org.openjdk.jmh.it.profilers.ItExternalProfiler org.openjdk.jmh.it.profilers.ChangeJVMOptsExternalProfiler org.openjdk.jmh.it.profilers.order.InternalProfiler1 org.openjdk.jmh.it.profilers.order.InternalProfiler2 org.openjdk.jmh.it.profilers.order.InternalProfiler3 org.openjdk.jmh.it.profilers.order.ExternalProfiler1 org.openjdk.jmh.it.profilers.order.ExternalProfiler2 org.openjdk.jmh.it.profilers.order.ExternalProfiler3jmh-1.37/jmh-core/000077500000000000000000000000001446271450100137325ustar00rootroot00000000000000jmh-1.37/jmh-core/LICENSE000066400000000000000000000455121446271450100147460ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-core/THIRD-PARTY000066400000000000000000000350611446271450100154310ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-core/pom.xml000066400000000000000000000221151446271450100152500ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent 1.37 JMH Core jmh-core jar Oracle http://openjdk.java.net/ 2012 The jmh is a Java harness for building, running, and analysing nano/micro/macro benchmarks written in Java and other languages targeting the JVM. junit junit test net.sf.jopt-simple jopt-simple org.apache.commons commons-math3 UTF-8 ${maven.build.timestamp} yyyy/MM/dd org.apache.maven.plugins maven-compiler-plugin true -proc:none -Xlint:serial true org.apache.maven.plugins maven-surefire-plugin true com.mycila.maven-license-plugin maven-license-plugin format process-sources
file:///${project.basedir}/../src/license/gpl_cpe/header.txt
true true PHP
org.apache.maven.plugins maven-site-plugin
org.apache.maven.wagon wagon-ssh src/main/resources/ true
org.apache.maven.plugins maven-site-plugin org.apache.maven.plugins maven-javadoc-plugin javadoc true http://download.oracle.com/javase/6/docs/api org.codehaus.mojo cobertura-maven-plugin org.apache.maven.plugins maven-surefire-report-plugin org.apache.maven.plugins maven-jxr-plugin org.codehaus.mojo findbugs-maven-plugin Max Low src/main/resources/findbugs.xml org.apache.maven.plugins maven-checkstyle-plugin false ${project.basedir}/src/main/resources/checkstyle.xml org.codehaus.mojo taglist-maven-plugin FIXME work FIXME: ignoreCase FIXME ignoreCase TODO work todo ignoreCase todo: ignoreCase @todo ignoreCase
jmh-1.37/jmh-core/src/000077500000000000000000000000001446271450100145215ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/000077500000000000000000000000001446271450100154455ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/000077500000000000000000000000001446271450100163665ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/000077500000000000000000000000001446271450100171555ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/000077500000000000000000000000001446271450100206075ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/000077500000000000000000000000001446271450100213655ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/Main.java000066400000000000000000000073411446271450100231210ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh; import org.openjdk.jmh.runner.*; import org.openjdk.jmh.runner.options.CommandLineOptionException; import org.openjdk.jmh.runner.options.CommandLineOptions; import org.openjdk.jmh.runner.options.VerboseMode; import java.io.IOException; /** * Main program entry point */ public class Main { public static void main(String[] argv) throws IOException { try { CommandLineOptions cmdOptions = new CommandLineOptions(argv); Runner runner = new Runner(cmdOptions); if (cmdOptions.shouldHelp()) { cmdOptions.showHelp(); return; } if (cmdOptions.shouldList()) { runner.list(); return; } if (cmdOptions.shouldListWithParams()) { runner.listWithParams(cmdOptions); return; } if (cmdOptions.shouldListProfilers()) { cmdOptions.listProfilers(); return; } if (cmdOptions.shouldListResultFormats()) { cmdOptions.listResultFormats(); return; } try { runner.run(); } catch (NoBenchmarksException e) { System.err.println("No matching benchmarks. Miss-spelled regexp?"); if (cmdOptions.verbosity().orElse(Defaults.VERBOSITY) != VerboseMode.EXTRA) { System.err.println("Use " + VerboseMode.EXTRA + " verbose mode to debug the pattern matching."); } else { runner.list(); } System.exit(1); } catch (ProfilersFailedException e) { // This is not exactly an error, print all messages and set the non-zero exit code. Throwable ex = e; while (ex != null) { System.err.println(ex.getMessage()); for (Throwable supp : ex.getSuppressed()) { System.err.println(supp.getMessage()); } ex = ex.getCause(); } System.exit(1); } catch (RunnerException e) { System.err.print("ERROR: "); e.printStackTrace(System.err); System.exit(1); } } catch (CommandLineOptionException e) { System.err.println("Error parsing command line:"); System.err.println(" " + e.getMessage()); System.exit(1); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/000077500000000000000000000000001446271450100237225ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/AuxCounters.java000066400000000000000000000105131446271450100270450ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

{@link AuxCounters} annotation can be used to mark {@link State} objects * as the bearers of auxiliary secondary results. Marking the class with this annotation * will make JMH to treat its public fields and result-returning public methods * as the base for the secondary benchmark metrics.

* *

Properties:

* *
    *
  • Auxiliary counters are not available for every {@link BenchmarkMode}, * because not every mode counts time or operations. {@link Mode#AverageTime} * and {@link Mode#Throughput} are always supported.
  • * *
  • {@link AuxCounters} annotation is only available for {@link Scope#Thread} * state objects. It is a compile-time error to use it with other states. This means * the counters are thread-local in nature.
  • * *
  • Only public fields and methods are considered as metrics. If you don't want * a field/method to be captured as metric, do not make it public.
  • * *
  • Only numeric fields and numeric-returning methods are considered as * metrics. These include all primitives and their corresponding boxed counterTypes, * except {@code boolean}/{@link Boolean} and {@code char}/{@link Character}. * It is a compile-time error to use the public field/method with incompatible type.
  • * *
  • Methods with {@code void} return type are exempted from type checking. * This means helper {@link Setup} and {@link TearDown} methods are fine in * {@link AuxCounters}.
  • * *
  • Public fields in {@link AuxCounters} instances would be reset before * starting the iteration, and read back at the end of iteration. This allows * benchmark code to avoid complicated lifecycle handling for these objects.
  • * *
  • The counter names are generated from field/method names. The namespace for * counters is shared across all states participating in the run. JMH will fail to * compile the benchmark if there is an ambiguity around what counter comes from * what {@link AuxCounters} class. *
  • *
* *

CAVEAT: THIS IS AN EXPERIMENTAL API, it may be changed or removed in future * without prior warning. This is a sharp tool, use with care.

*/ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface AuxCounters { Type value() default Type.OPERATIONS; enum Type { /** * Counts "operations", which should be relevant to the number of * times {@link Benchmark} method was executed. If this counter is * incremented on each {@link Benchmark} method invocation, then it * will produce a metric similar to the primary benchmark result. * This counter will be normalized to benchmark time by the harness. */ OPERATIONS, /** * Counts "events", the one-off things in the lifetime of workload. * This counter would not get normalized to time. */ EVENTS, ; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Benchmark.java000066400000000000000000000066651446271450100264740ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

{@link Benchmark} annotates the benchmark method.

* *

JMH will produce the generated benchmark code for this method during compilation, * register this method as the benchmark in the benchmark list, read out the default * values from the annotations, and generally prepare the environment for the benchmark * to run.

* *

Benchmarks may use annotations to control different things in their operations. * See {@link org.openjdk.jmh.annotations} package for available annotations, read their * Javadocs, and/or look through * * JMH samples for their canonical uses. As the rule of thumb, most annotations * may be placed either at the {@link Benchmark} method, or at the enclosing class, * to be inherited by all {@link Benchmark} methods in the class.

* *

{@link Benchmark} demarcates the benchmark payload, and JMH treats it specifically * as the wrapper which contains the benchmark code. In order to run the benchmark reliably, * JMH enforces a few stringent properties for these wrapper methods, including, but not * limited to:

*
    *
  • Method should be public
  • *
  • Arguments may only include either {@link State} classes, which JMH will inject * while calling the method (see {@link State} for more details), or JMH infrastructure * classes, like {@link org.openjdk.jmh.infra.Control}, or {@link org.openjdk.jmh.infra.Blackhole}
  • *
  • Method can only be synchronized if a relevant {@link State} is placed * on the enclosing class.
  • *
* *

If you want to benchmark methods that break these properties, you have to write them * out as distinct methods and call them from {@link Benchmark} method.

* *

Benchmark method may declare Exceptions and Throwables to throw. Any exception actually * raised and thrown will be treated as benchmark failure.

*/ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Benchmark { } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/BenchmarkMode.java000066400000000000000000000040711446271450100272660ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

Benchmark mode declares the default modes in which this benchmark * would run. See {@link Mode} for available benchmark modes.

* *

This annotation may be put at {@link Benchmark} method to have effect * on that method only, or at the enclosing class instance to have the effect * over all {@link Benchmark} methods in the class. This annotation may be * overridden with the runtime options.

*/ @Inherited @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface BenchmarkMode { /** * @return Which benchmark modes to use. * @see Mode */ Mode[] value(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/CompilerControl.java000066400000000000000000000064221446271450100277040ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

Compiler control annotation may be used to affect the compilation of * particular methods in the benchmarks.

* *

JMH interfaces with the JVM by the means of CompilerCommand interface. * These annotations only work with forking enabled. Non-forked runs will not be * able to pass the hints to the compiler. Also, these control annotations might * get freely ignored by the compiler, reduced to no-ops, or otherwise invalidated. * Be cautious, and check the compiler logs and/or the generated code to see if * the effect is there.

* *

This annotation may be put at a method to have effect on that method only, or * at the enclosing class instance to have the effect over all methods in the class. * Remarkably, this annotation works on any class/method, even those not marked by * other JMH annotations.

*/ @Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface CompilerControl { /** * The compilation mode. * @return mode */ Mode value(); /** * Compilation mode. */ enum Mode { /** * Insert the breakpoint into the generated compiled code. */ BREAK("break"), /** * Print the method and it's profile. */ PRINT("print"), /** * Exclude the method from the compilation. */ EXCLUDE("exclude"), /** * Force inline. */ INLINE("inline"), /** * Force skip inline. */ DONT_INLINE("dontinline"), /** * Compile only this method, and nothing else. */ COMPILE_ONLY("compileonly"),; private final String command; Mode(String command) { this.command = command; } public String command() { return command; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Fork.java000066400000000000000000000052031446271450100254660ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Fork annotation allows to set the default forking parameters for the benchmark. * *

This annotation may be put at {@link Benchmark} method to have effect on that * method only, or at the enclosing class instance to have the effect over all * {@link Benchmark} methods in the class. This annotation may be overridden with * the runtime options.

*/ @Inherited @Target({ElementType.METHOD,ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Fork { int BLANK_FORKS = -1; String BLANK_ARGS = "blank_blank_blank_2014"; /** @return number of times harness should fork, zero means "no fork" */ int value() default BLANK_FORKS; /** @return number of times harness should fork and ignore the results */ int warmups() default BLANK_FORKS; /** @return JVM executable to run with */ String jvm() default BLANK_ARGS; /** @return JVM arguments to replace in the command line */ String[] jvmArgs() default { BLANK_ARGS }; /** @return JVM arguments to prepend in the command line */ String[] jvmArgsPrepend() default { BLANK_ARGS }; /** @return JVM arguments to append in the command line */ String[] jvmArgsAppend() default { BLANK_ARGS }; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Group.java000066400000000000000000000054601446271450100256660ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

Execution group.

* *

Multiple {@link Benchmark} methods can be bound in the execution group * to produce the asymmetric benchmark. Each execution group contains of one * or more threads. Each thread within a particular execution group executes * one of {@link Group}-annotated {@link Benchmark} methods. The number of * threads executing a particular {@link Benchmark} defaults to a single thread, * and can be overridden by {@link GroupThreads}.

* *

Multiple copies of an execution group may participate in the run, and * the number of groups depends on the number of worker threads requested. * JMH will take the requested number of worker threads, round it up to execution * group size, and then distribute the threads among the (multiple) groups. * Among other things, this guarantees fully-populated execution groups.

*

For example, running {@link Group} with two {@link Benchmark} methods, * each having {@link GroupThreads}(4), will run 8*N threads, where N is an * integer.

* *

The group tag is used as the generated benchmark name. The result of each * benchmark method in isolation is recorded as secondary result named by the * original method name.

*/ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Group { /** * Group tag. Should be a valid Java identifier. * @return group tag */ String value() default "group"; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/GroupThreads.java000066400000000000000000000034351446271450100272010ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

GroupThreads defines how many threads are participating in running * a particular {@link Benchmark} method in the group.

* * @see Group */ @Inherited @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface GroupThreads { /** @return number of threads to run the concrete method with. */ int value() default 1; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Level.java000066400000000000000000000074361446271450100256460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; /** * Control when to run the fixture methods. * * @see Setup * @see TearDown */ public enum Level { /** * Trial level: to be executed before/after each run of the benchmark. * *

Trial is the set of benchmark iterations.

*/ Trial, /** * Iteration level: to be executed before/after each iteration of the benchmark. * *

Iteration is the set of benchmark invocations.

*/ Iteration, /** * Invocation level: to be executed for each benchmark method execution. * *

WARNING: HERE BE DRAGONS! THIS IS A SHARP TOOL. * MAKE SURE YOU UNDERSTAND THE REASONING AND THE IMPLICATIONS * OF THE WARNINGS BELOW BEFORE EVEN CONSIDERING USING THIS LEVEL.

* *

This level is only usable for benchmarks taking more than a millisecond * per single {@link Benchmark} method invocation. It is a good idea to validate * the impact for your case on ad-hoc basis as well.

* *

WARNING #1: Since we have to subtract the setup/teardown costs from * the benchmark time, on this level, we have to timestamp *each* benchmark * invocation. If the benchmarked method is small, then we saturate the * system with timestamp requests, which introduce artificial latency, * throughput, and scalability bottlenecks.

* *

WARNING #2: Since we measure individual invocation timings with this * level, we probably set ourselves up for (coordinated) omission. That means * the hiccups in measurement can be hidden from timing measurement, and * can introduce surprising results. For example, when we use timings to * understand the benchmark throughput, the omitted timing measurement will * result in lower aggregate time, and fictionally *larger* throughput.

* *

WARNING #3: In order to maintain the same sharing behavior as other * Levels, we sometimes have to synchronize (arbitrage) the access to * {@link State} objects. Other levels do this outside the measurement, * but at this level, we have to synchronize on *critical path*, further * offsetting the measurement.

* *

WARNING #4: Current implementation allows the helper method execution * at this Level to overlap with the benchmark invocation itself in order * to simplify arbitrage. That matters in multi-threaded benchmarks, when * one worker thread executing {@link Benchmark} method may observe other * worker thread already calling {@link TearDown} for the same object.

*/ Invocation, } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Measurement.java000066400000000000000000000047571446271450100270670ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.concurrent.TimeUnit; /** *

Measurement annotations allows to set the default measurement parameters for * the benchmark.

* *

This annotation may be put at {@link Benchmark} method to have effect on that * method only, or at the enclosing class instance to have the effect over all * {@link Benchmark} methods in the class. This annotation may be overridden with * the runtime options.

* * @see Warmup */ @Inherited @Target({ElementType.METHOD,ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Measurement { int BLANK_ITERATIONS = -1; int BLANK_TIME = -1; int BLANK_BATCHSIZE = -1; /** @return Number of measurement iterations */ int iterations() default BLANK_ITERATIONS; /** @return Time of each measurement iteration */ int time() default BLANK_TIME; /** @return Time unit for measurement iteration duration */ TimeUnit timeUnit() default TimeUnit.SECONDS; /** @return Batch size: number of benchmark method calls per operation */ int batchSize() default BLANK_BATCHSIZE; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java000066400000000000000000000120011446271450100254430ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.util.ArrayList; import java.util.List; /** * Benchmark mode. */ public enum Mode { /** *

Throughput: operations per unit of time.

* *

Runs by continuously calling {@link Benchmark} methods, * counting the total throughput over all worker threads. This mode is time-based, and it will * run until the iteration time expires.

*/ Throughput("thrpt", "Throughput, ops/time"), /** *

Average time: average time per per operation.

* *

Runs by continuously calling {@link Benchmark} methods, * counting the average time to call over all worker threads. This is the inverse of {@link Mode#Throughput}, * but with different aggregation policy. This mode is time-based, and it will run until the iteration time * expires.

*/ AverageTime("avgt", "Average time, time/op"), /** *

Sample time: samples the time for each operation.

* *

Runs by continuously calling {@link Benchmark} methods, * and randomly samples the time needed for the call. This mode automatically adjusts the sampling * frequency, but may omit some pauses which missed the sampling measurement. This mode is time-based, and it will * run until the iteration time expires.

*/ SampleTime("sample", "Sampling time"), /** *

Single shot time: measures the time for a single operation.

* *

Runs by calling {@link Benchmark} once and measuring its time. * This mode is useful to estimate the "cold" performance when you don't want to hide the warmup invocations, or * if you want to see the progress from call to call, or you want to record every single sample. This mode is * work-based, and will run only for a single invocation of {@link Benchmark} * method.

* * Caveats for this mode include: *
    *
  • More warmup/measurement iterations are generally required.
  • *
  • Timers overhead might be significant if benchmarks are small; switch to {@link #SampleTime} mode if * that is a problem.
  • *
*/ SingleShotTime("ss", "Single shot invocation time"), /** * Meta-mode: all the benchmark modes. * This is mostly useful for internal JMH testing. */ All("all", "All benchmark modes"), ; private final String shortLabel; private final String longLabel; Mode(String shortLabel, String longLabel) { this.shortLabel = shortLabel; this.longLabel = longLabel; } public String shortLabel() { return shortLabel; } public String longLabel() { return longLabel; } public static Mode deepValueOf(String name) { try { return Mode.valueOf(name); } catch (IllegalArgumentException iae) { Mode inferred = null; for (Mode type : values()) { if (type.shortLabel().startsWith(name)) { if (inferred == null) { inferred = type; } else { throw new IllegalStateException("Unable to parse benchmark mode, ambiguous prefix given: \"" + name + "\"\n" + "Known values are " + getKnown()); } } } if (inferred != null) { return inferred; } else { throw new IllegalStateException("Unable to parse benchmark mode: \"" + name + "\"\n" + "Known values are " + getKnown()); } } } public static List getKnown() { List res = new ArrayList<>(); for (Mode type : Mode.values()) { res.add(type.name() + "/" + type.shortLabel()); } return res; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/OperationsPerInvocation.java000066400000000000000000000046351446271450100314210ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

OperationsPerInvocation annotations allows to communicate the benchmark does more than * one operation, and let JMH to adjust the scores appropriately.

* *

For example, a benchmark which uses the internal loop to have multiple operations, may * want to measure the performance of a single operation:

* *
 * @Benchmark
 * @OperationsPerInvocation(10)
 * public void test() {
 *      for (int i = 0; i < 10; i++) {
 *          // do something
 *      }
 * }
 * 
* *

This annotation may be put at {@link Benchmark} method to have effect on that method * only, or at the enclosing class instance to have the effect over all {@link Benchmark} * methods in the class.

*/ @Inherited @Target({ElementType.METHOD,ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface OperationsPerInvocation { /** * @return Number of operations per single {@link Benchmark} call. */ int value() default 1; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/OutputTimeUnit.java000066400000000000000000000040151446271450100275440ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.concurrent.TimeUnit; /** *

OutputTimeUnit provides the default time unit to report the results in.

* *

This annotation may be put at {@link Benchmark} method to have effect on that * method only, or at the enclosing class instance to have the effect over all * {@link Benchmark} methods in the class. This annotation may be overridden with * the runtime options.

*/ @Inherited @Target({ElementType.METHOD,ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface OutputTimeUnit { /** * @return Time unit to use. */ TimeUnit value(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Param.java000066400000000000000000000055701446271450100256340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

Marks the configurable parameter in the benchmark.

* *

{@link Param} fields should be non-final fields, * and should only reside in {@link State} classes. JMH will inject * the value into the annotated field before any {@link Setup} method * is called. It is not guaranteed the field value would be accessible * in any initializer or any constructor of {@link State}.

* *

Parameters are acceptable on any primitive type, primitive wrapper type, * a String, or an Enum. The annotation value is given in String, and will be * coerced as required to match the field type.

* *

Parameters should normally provide the default values which make * benchmark runnable even without the explicit parameters set for the run. * The only exception is {@link Param} over {@link java.lang.Enum}, which * will implicitly have the default value set encompassing all enum constants.

* *

When multiple {@link Param}-s are needed for the benchmark run, * JMH will compute the outer product of all the parameters in the run.

*/ @Inherited @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface Param { String BLANK_ARGS = "blank_blank_blank_2014"; /** * Default values sequence for the parameter. By default, the parameter * values will be traversed during the run in the given order. * * @return values sequence to follow. */ String[] value() default { BLANK_ARGS }; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Scope.java000066400000000000000000000052401446271450100256370ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; /** * {@link State} scope. */ public enum Scope { /** *

Benchmark state scope.

* *

With benchmark scope, all instances of the same type will be shared across all * worker threads.

* *

{@link Setup} and {@link TearDown} methods on this state object would be performed * by one of the worker threads, and only once per {@link Level}. * No other threads would ever touch the state object.

*/ Benchmark, /** *

Group state scope.

* *

With group scope, all instances of the same type will be shared across all * threads within the same group. Each thread group will be supplied with its own * state object.

* *

{@link Setup} and {@link TearDown} methods on this state object would be performed * by one of the group threads, and only once per {@link Level}. * No other threads would ever touch the state object.

* * @see Group */ Group, /** *

Thread state scope.

* *

With thread scope, all instances of the same type are distinct, even if multiple * state objects are injected in the same benchmark

* *

{@link Setup} and {@link TearDown} methods on this state object would be performed * by single worker thread exclusively, and only once per {@link Level}. * No other threads would ever touch the state object.

* */ Thread, } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Setup.java000066400000000000000000000042541446271450100256720ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

Setup marks the fixture method to be run before the benchmark.

* *

Since fixture methods manage the {@link State} lifecycles, {@link Setup} * can only be declared in {@link State} classes. The {@link Setup} method will * be executed by a thread which has the access to {@link State}, and it is not * defined which thread exactly. Note that means {@link TearDown} may be executed * by a different thread, if {@link State} is shared between the threads.

* *

Uses may optionally provide the {@link Level} at which the fixture method * should run.

* * @see State */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Setup { /** * @return Level of this method. * @see Level */ Level value() default Level.Trial; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/State.java000066400000000000000000000045651446271450100256570ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

Marks the state object.

* *

State objects naturally encapsulate the state on which benchmark is working on. * The {@link Scope} of state object defines to which extent it is shared among the * worker threads.

* *

State objects are usually injected into {@link Benchmark} methods as arguments, * and JMH takes care of their instantiation and sharing. State objects may also be * injected into {@link Setup} and {@link TearDown} methods of other {@link State} * objects to get the staged initialization. In that case, the dependency graph * between the {@link State}-s should be directed acyclic graph.

* *

State objects may be inherited: you can place {@link State} on a super class and * use subclasses as states.

*/ @Inherited @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface State { /** * State scope. * @return state scope * @see Scope */ Scope value(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/TearDown.java000066400000000000000000000043011446271450100263060ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

TearDown marks the fixture method to be run after the benchmark.

* *

Since fixture methods manage the {@link State} lifecycles, {@link TearDown} * can only be declared in {@link State} classes. The {@link TearDown} method will * be executed by a thread which has the access to {@link State}, and it is not * defined which thread exactly. Note that means {@link Setup} may be executed * by a different thread, if {@link State} is shared between the threads.

* *

Uses may optionally provide the {@link Level} at which the fixture method * should run.

* * @see State */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface TearDown { /** * @return At which level to run this fixture. * @see Level */ Level value() default Level.Trial; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Threads.java000066400000000000000000000042321446271450100261600ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** *

Threads annotation provides the default number of threads to run.

* *

This annotation may be put at {@link Benchmark} method to have effect * on that method only, or at the enclosing class instance to have the effect * over all {@link Benchmark} methods in the class. This annotation may be * overridden with the runtime options.

*/ @Inherited @Target({ElementType.METHOD,ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Threads { /** * The magic value for MAX threads. * This means Runtime.getRuntime().availableProcessors() threads. */ int MAX = -1; /** * @return Number of threads; use Threads.MAX to run with all available threads. */ int value(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Timeout.java000066400000000000000000000042421446271450100262150ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.concurrent.TimeUnit; /** *

Timeout annotation allows to set the default timeout parameters for the benchmark.

* *

This annotation may be put at {@link org.openjdk.jmh.annotations.Benchmark} method to have effect on that method * only, or at the enclosing class instance to have the effect over all {@link org.openjdk.jmh.annotations.Benchmark} * methods in the class. This annotation may be overridden with the runtime options.

*/ @Target({ElementType.METHOD,ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface Timeout { /** @return Timeout for each iteration */ int time(); /** @return Time unit for timeout duration */ TimeUnit timeUnit() default TimeUnit.SECONDS; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/annotations/Warmup.java000066400000000000000000000047201446271450100260430ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.concurrent.TimeUnit; /** *

Warmup annotation allows to set the default warmup parameters for the benchmark.

* *

This annotation may be put at {@link Benchmark} method to have effect on that method * only, or at the enclosing class instance to have the effect over all {@link Benchmark} * methods in the class. This annotation may be overridden with the runtime options.

* * @see Measurement */ @Target({ElementType.METHOD,ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface Warmup { int BLANK_ITERATIONS = -1; int BLANK_TIME = -1; int BLANK_BATCHSIZE = -1; /** @return Number of warmup iterations */ int iterations() default BLANK_ITERATIONS; /** @return Time for each warmup iteration */ int time() default BLANK_TIME; /** @return Time unit for warmup iteration duration */ TimeUnit timeUnit() default TimeUnit.SECONDS; /** @return batch size: number of benchmark method calls per operation */ int batchSize() default BLANK_BATCHSIZE; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/000077500000000000000000000000001446271450100235365ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/000077500000000000000000000000001446271450100244665ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java000066400000000000000000001531661446271450100311060ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.*; import org.openjdk.jmh.results.*; import org.openjdk.jmh.runner.*; import org.openjdk.jmh.runner.Defaults; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.SampleBuffer; import java.io.*; import java.lang.reflect.Field; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * Benchmark generator. * *

Benchmark generator is the agnostic piece of code which generates * synthetic Java code for JMH benchmarks. {@link GeneratorSource} is * used to feed the generator with the required metadata.

*/ public class BenchmarkGenerator { private static final String JMH_STUB_SUFFIX = "_jmhStub"; private static final String JMH_TESTCLASS_SUFFIX = "_jmhTest"; protected static final String JMH_GENERATED_SUBPACKAGE = "jmh_generated"; private final Set benchmarkInfos; private final CompilerControlPlugin compilerControl; private final Set processedBenchmarks; private final BenchmarkGeneratorSession session; public BenchmarkGenerator() { benchmarkInfos = new HashSet<>(); processedBenchmarks = new HashSet<>(); compilerControl = new CompilerControlPlugin(); session = new BenchmarkGeneratorSession(); } /** * Execute the next phase of benchmark generation. * Multiple calls to this method are acceptable, even with the difference sources * * @param source generator source to get the metadata from * @param destination generator destination to write the results to */ public void generate(GeneratorSource source, GeneratorDestination destination) { try { // Build a Set of classes with a list of annotated methods Multimap clazzes = buildAnnotatedSet(source); // Generate code for all found Classes and Methods for (ClassInfo clazz : clazzes.keys()) { if (!processedBenchmarks.add(clazz.getQualifiedName())) continue; try { validateBenchmark(clazz, clazzes.get(clazz)); Collection infos = makeBenchmarkInfo(clazz, clazzes.get(clazz)); for (BenchmarkInfo info : infos) { generateClass(destination, clazz, info); } benchmarkInfos.addAll(infos); } catch (GenerationException ge) { destination.printError(ge.getMessage(), ge.getElement()); } } /* * JMH stubs should not be inlined to start the inlining budget from the hottest loop. * We would like to accurately track the things we do not want to inline, but * unfortunately the Hotspot's CompilerOracle is not scaling well with the number of compiler * commands. Therefore, in order to cut down the number of compiler commands, we opt to * blankly forbid the inlining all methods that look like JMH stubs. * * See: https://bugs.openjdk.java.net/browse/JDK-8057169 */ for (Mode mode : Mode.values()) { compilerControl.alwaysDontInline("*", "*_" + mode.shortLabel() + JMH_STUB_SUFFIX); } compilerControl.process(source, destination); } catch (Throwable t) { destination.printError("Annotation generator had thrown the exception.", t); } } /** * Finish generating the benchmarks. * Must be called at the end of generation. * * @param source source generator to use * @param destination generator destination to write the results to */ public void complete(GeneratorSource source, GeneratorDestination destination) { compilerControl.finish(source, destination); // Processing completed, final round. // Collect all benchmark entries here Set entries = new HashSet<>(); // Try to read the benchmark entries from the previous generator sessions. // Incremental compilation may add or remove @Benchmark entries. New entries // are discovered and added from the current compilation session. It is harder // to detect removed @Benchmark entries. To do so, we are overwriting all benchmark // records that belong to a current compilation unit. Multimap entriesByQName = new HashMultimap<>(); try (InputStream stream = destination.getResource(BenchmarkList.BENCHMARK_LIST.substring(1))) { for (BenchmarkListEntry ble : BenchmarkList.readBenchmarkList(stream)) { entries.add(ble); entriesByQName.put(ble.getUserClassQName(), ble); } } catch (IOException e) { // okay, move on } catch (UnsupportedOperationException e) { destination.printError("Unable to read the existing benchmark list.", e); } // Generate new benchmark entries for (BenchmarkInfo info : benchmarkInfos) { try { MethodGroup group = info.methodGroup; for (Mode m : group.getModes()) { BenchmarkListEntry br = new BenchmarkListEntry( info.userClassQName, info.generatedClassQName, group.getName(), m, group.getTotalThreadCount(), group.getGroupThreads(), group.getGroupLabels(), group.getWarmupIterations(), group.getWarmupTime(), group.getWarmupBatchSize(), group.getMeasurementIterations(), group.getMeasurementTime(), group.getMeasurementBatchSize(), group.getForks(), group.getWarmupForks(), group.getJvm(), group.getJvmArgs(), group.getJvmArgsPrepend(), group.getJvmArgsAppend(), group.getParams(), group.getOutputTimeUnit(), group.getOperationsPerInvocation(), group.getTimeout() ); if (entriesByQName.keys().contains(info.userClassQName)) { destination.printNote("Benchmark entries for " + info.userClassQName + " already exist, overwriting"); entries.removeAll(entriesByQName.get(info.userClassQName)); entriesByQName.remove(info.userClassQName); } entries.add(br); } } catch (GenerationException ge) { destination.printError(ge.getMessage(), ge.getElement()); } } try (OutputStream stream = destination.newResource(BenchmarkList.BENCHMARK_LIST.substring(1))) { BenchmarkList.writeBenchmarkList(stream, entries); } catch (IOException ex) { destination.printError("Error writing benchmark list", ex); } } /** * Build a set of Classes which has annotated methods in them * * @return for all methods annotated with $annotation, returns Map> */ private Multimap buildAnnotatedSet(GeneratorSource source) { // Transitively close the hierarchy: // If superclass has a @Benchmark method, then all subclasses also have it. // We skip the generated classes, which we had probably generated during the previous rounds // of processing. Abstract classes are of no interest for us either. Multimap result = new HashMultimap<>(); for (ClassInfo currentClass : source.getClasses()) { if (currentClass.getQualifiedName().contains(JMH_GENERATED_SUBPACKAGE)) continue; if (currentClass.isAbstract()) continue; ClassInfo walk = currentClass; do { for (MethodInfo mi : walk.getMethods()) { Benchmark ann = mi.getAnnotation(Benchmark.class); if (ann != null) { result.put(currentClass, mi); } } } while ((walk = walk.getSuperClass()) != null); } return result; } /** * Do basic benchmark validation. */ private void validateBenchmark(ClassInfo clazz, Collection methods) { if (clazz.getPackageName().isEmpty()) { throw new GenerationException("Benchmark class should have package other than default.", clazz); } if (clazz.isFinal()) { throw new GenerationException("Benchmark classes should not be final.", clazz); } // validate all arguments are @State-s for (MethodInfo e : methods) { StateObjectHandler.validateStateArgs(e); } boolean explicitState = BenchmarkGeneratorUtils.getAnnSuper(clazz, State.class) != null; // validate if enclosing class is implicit @State if (explicitState) { StateObjectHandler.validateState(clazz); } // validate no @State cycles for (MethodInfo e : methods) { StateObjectHandler.validateNoCycles(e); } // validate against rogue fields if (!explicitState || clazz.isAbstract()) { for (FieldInfo fi : BenchmarkGeneratorUtils.getAllFields(clazz)) { // allow static fields if (fi.isStatic()) continue; throw new GenerationException( "Field \"" + fi.getName() + "\" is declared within " + "a class not having @" + State.class.getSimpleName() + " annotation. " + "This is prohibited because it can result in unspecified behavior.", fi); } } // validate rogue annotations on classes BenchmarkGeneratorUtils.checkAnnotations(clazz); // validate rogue annotations on fields for (FieldInfo fi : BenchmarkGeneratorUtils.getAllFields(clazz)) { BenchmarkGeneratorUtils.checkAnnotations(fi); } // validate rogue annotations on methods for (MethodInfo mi : methods) { BenchmarkGeneratorUtils.checkAnnotations(mi); } // check modifiers for (MethodInfo m : methods) { if (!m.isPublic()) { throw new GenerationException("@" + Benchmark.class.getSimpleName() + " method should be public.", m); } if (m.isAbstract()) { throw new GenerationException("@" + Benchmark.class.getSimpleName() + " method can not be abstract.", m); } if (m.isSynchronized()) { State annState = BenchmarkGeneratorUtils.getAnnSuper(m, State.class); if (annState == null) { throw new GenerationException("@" + Benchmark.class.getSimpleName() + " method can only be synchronized if the enclosing class is annotated with " + "@" + State.class.getSimpleName() + ".", m); } else { if (m.isStatic() && annState.value() != Scope.Benchmark) { throw new GenerationException("@" + Benchmark.class.getSimpleName() + " method can only be static and synchronized if the enclosing class is annotated with " + "@" + State.class.getSimpleName() + "(" + Scope.class.getSimpleName() + "." + Scope.Benchmark + ").", m); } } } } // check annotations for (MethodInfo m : methods) { OperationsPerInvocation opi = BenchmarkGeneratorUtils.getAnnSuper(m, clazz, OperationsPerInvocation.class); if (opi != null && opi.value() < 1) { throw new GenerationException("The " + OperationsPerInvocation.class.getSimpleName() + " needs to be greater than 0.", m); } } // validate @Group-s for (MethodInfo m : methods) { if (m.getAnnotation(Group.class) != null && m.getAnnotation(Threads.class) != null) { throw new GenerationException("@" + Threads.class.getSimpleName() + " annotation is placed within " + "the benchmark method with @" + Group.class.getSimpleName() + " annotation. " + "This is prohibited because it is ambiguous. " + "Did you mean @" + GroupThreads.class.getSimpleName() + " instead?", m); } } } /** * validate benchmark info * * @param info benchmark info to validate */ private void validateBenchmarkInfo(BenchmarkInfo info) { // check the @Group preconditions, // ban some of the surprising configurations // MethodGroup group = info.methodGroup; if (group.methods().size() == 1) { MethodInfo meth = group.methods().iterator().next(); if (meth.getAnnotation(Group.class) == null) { for (ParameterInfo param : meth.getParameters()) { State stateAnn = BenchmarkGeneratorUtils.getAnnSuper(param.getType(), State.class); if (stateAnn != null && stateAnn.value() == Scope.Group) { throw new GenerationException( "Only @" + Group.class.getSimpleName() + " methods can reference @" + State.class.getSimpleName() + "(" + Scope.class.getSimpleName() + "." + Scope.Group + ") states.", meth); } } State stateAnn = BenchmarkGeneratorUtils.getAnnSuper(meth.getDeclaringClass(), State.class); if (stateAnn != null && stateAnn.value() == Scope.Group) { throw new GenerationException( "Only @" + Group.class.getSimpleName() + " methods can implicitly reference @" + State.class.getSimpleName() + "(" + Scope.class.getSimpleName() + "." + Scope.Group + ") states.", meth); } } } else { for (MethodInfo m : group.methods()) { if (m.getAnnotation(Group.class) == null) { throw new GenerationException( "Internal error: multiple methods per @" + Group.class.getSimpleName() + ", but not all methods have @" + Group.class.getSimpleName(), m); } } } } /** * Generate BenchmarkInfo for given class. * We will figure out method groups at this point. * * * @param clazz holder class * @param methods annotated methods * @return BenchmarkInfo */ private Collection makeBenchmarkInfo(ClassInfo clazz, Collection methods) { Map result = new TreeMap<>(); for (MethodInfo method : methods) { Group groupAnn = method.getAnnotation(Group.class); String groupName = (groupAnn != null) ? groupAnn.value() : method.getName(); if (!BenchmarkGeneratorUtils.checkJavaIdentifier(groupName)) { throw new GenerationException("Group name should be the legal Java identifier.", method); } MethodGroup group = result.get(groupName); if (group == null) { group = new MethodGroup(clazz, groupName); result.put(groupName, group); } BenchmarkMode mbAn = BenchmarkGeneratorUtils.getAnnSuper(method, clazz, BenchmarkMode.class); if (mbAn != null) { group.addModes(mbAn.value()); } group.addStrictFP(clazz.isStrictFP()); group.addStrictFP(method.isStrictFP()); group.addMethod(method, (method.getAnnotation(GroupThreads.class) != null) ? method.getAnnotation(GroupThreads.class).value() : 1); // Discovering @Params, part 1: // For each parameter, walk the type hierarchy up to discover inherited @Param fields in @State objects. for (ParameterInfo pi : method.getParameters()) { BenchmarkGeneratorUtils.addParameterValuesToGroup(pi.getType(), group); } // Discovering @Params, part 2: // Walk the type hierarchy up to discover inherited @Param fields for class. BenchmarkGeneratorUtils.addParameterValuesToGroup(clazz, group); } // enforce the default value for (MethodGroup group : result.values()) { if (group.getModes().isEmpty()) { group.addModes(Defaults.BENCHMARK_MODE); } } Collection benchmarks = new ArrayList<>(); for (MethodGroup group : result.values()) { String sourcePackage = clazz.getPackageName(); String generatedPackageName = sourcePackage + "." + JMH_GENERATED_SUBPACKAGE; String generatedClassName = BenchmarkGeneratorUtils.getGeneratedName(clazz) + "_" + group.getName() + JMH_TESTCLASS_SUFFIX; BenchmarkInfo info = new BenchmarkInfo(clazz.getQualifiedName(), generatedPackageName, generatedClassName, group); validateBenchmarkInfo(info); benchmarks.add(info); } return benchmarks; } /** * Create and generate Java code for a class and it's methods */ private void generateClass(GeneratorDestination destination, ClassInfo classInfo, BenchmarkInfo info) throws IOException { StateObjectHandler states = new StateObjectHandler(compilerControl); // bind all methods states.bindMethods(classInfo, info.methodGroup); // Create file and open an outputstream PrintWriter writer = new PrintWriter(destination.newClass(info.generatedClassQName, classInfo.getQualifiedName()), false); // Write package and imports writer.println("package " + info.generatedPackageName + ';'); writer.println(); generateImport(writer); states.addImports(writer); // Write class header writer.println("public final class " + info.generatedClassName + " {"); writer.println(); // generate padding Paddings.padding(writer, "p"); writer.println(ident(1) + "int startRndMask;"); writer.println(ident(1) + "BenchmarkParams benchmarkParams;"); writer.println(ident(1) + "IterationParams iterationParams;"); writer.println(ident(1) + "ThreadParams threadParams;"); writer.println(ident(1) + "Blackhole blackhole;"); writer.println(ident(1) + "Control notifyControl;"); // write all methods for (Mode benchmarkKind : Mode.values()) { if (benchmarkKind == Mode.All) continue; generateMethod(benchmarkKind, writer, info.methodGroup, states); } // Write out state initializers for (String s : states.getStateInitializers()) { writer.println(ident(1) + s); } writer.println(); // Write out the required fields for (String s : states.getFields()) { writer.println(ident(1) + s); } writer.println(); // Write out the required objects states.writeStateOverrides(session, destination); // Finish class writer.println("}"); writer.println(); writer.close(); } private void generateImport(PrintWriter writer) { Class[] imports = new Class[]{ List.class, AtomicInteger.class, Collection.class, ArrayList.class, TimeUnit.class, CompilerControl.class, InfraControl.class, ThreadParams.class, BenchmarkTaskResult.class, Result.class, ThroughputResult.class, AverageTimeResult.class, SampleTimeResult.class, SingleShotResult.class, SampleBuffer.class, Mode.class, Fork.class, Measurement.class, Threads.class, Warmup.class, BenchmarkMode.class, RawResults.class, ResultRole.class, Field.class, BenchmarkParams.class, IterationParams.class, Blackhole.class, Control.class, ScalarResult.class, AggregationPolicy.class, FailureAssistException.class }; for (Class c : imports) { writer.println("import " + c.getName() + ';'); } writer.println(); } /** * Generate the method for a specific benchmark method */ private void generateMethod(Mode benchmarkKind, PrintWriter writer, MethodGroup methodGroup, StateObjectHandler states) { writer.println(); switch (benchmarkKind) { case Throughput: generateThroughput(writer, benchmarkKind, methodGroup, states); break; case AverageTime: generateAverageTime(writer, benchmarkKind, methodGroup, states); break; case SampleTime: generateSampleTime(writer, benchmarkKind, methodGroup, states); break; case SingleShotTime: generateSingleShotTime(writer, benchmarkKind, methodGroup, states); break; default: throw new AssertionError("Shouldn't be here"); } } private void generateThroughput(PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { writer.println(ident(1) + "public BenchmarkTaskResult " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {"); methodProlog(writer); boolean isSingleMethod = (methodGroup.methods().size() == 1); int subGroup = -1; for (MethodInfo method : methodGroup.methods()) { subGroup++; writer.println(ident(2) + "if (threadParams.getSubgroupIndex() == " + subGroup + ") {"); writer.println(ident(3) + "RawResults res = new RawResults();"); iterationProlog(writer, 3, method, states); // synchronize iterations prolog: announce ready writer.println(ident(3) + "control.announceWarmupReady();"); // synchronize iterations prolog: catchup loop writer.println(ident(3) + "while (control.warmupShouldWait) {"); invocationProlog(writer, 4, method, states, false); writer.println(ident(4) + emitCall(method, states) + ';'); invocationEpilog(writer, 4, method, states, false); writer.println(ident(4) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(4) + "res.allOps++;"); writer.println(ident(3) + "}"); writer.println(); // control objects get a special treatment writer.println(ident(3) + "notifyControl.startMeasurement = true;"); // measurement loop call writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + "(" + getStubArgs() + prefix(states.getArgList(method)) + ");"); // control objects get a special treatment writer.println(ident(3) + "notifyControl.stopMeasurement = true;"); // synchronize iterations epilog: announce ready writer.println(ident(3) + "control.announceWarmdownReady();"); // synchronize iterations epilog: catchup loop writer.println(ident(3) + "try {"); writer.println(ident(4) + "while (control.warmdownShouldWait) {"); invocationProlog(writer, 5, method, states, false); writer.println(ident(5) + emitCall(method, states) + ';'); invocationEpilog(writer, 5, method, states, false); writer.println(ident(5) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(5) + "res.allOps++;"); writer.println(ident(4) + "}"); writer.println(ident(3) + "} catch (Throwable e) {"); writer.println(ident(4) + "if (!(e instanceof InterruptedException)) throw e;"); writer.println(ident(3) + "}"); writer.println(ident(3) + "control.preTearDown();"); // iteration prolog iterationEpilog(writer, 3, method, states); writer.println(ident(3) + "res.allOps += res.measuredOps;"); /* Adjust the operation counts: 1) res.measuredOps counted the individual @Benchmark invocations. Therefore, we need to adjust for opsPerInv (pretending each @Benchmark invocation counts as $opsPerInv ops); and we need to adjust down for $batchSize (pretending we had the batched run, and $batchSize @Benchmark invocations counted as single op); 2) res.allOps counted the individual @Benchmark invocations as well; the same reasoning applies. It's prudent to make the multiplication first to get more accuracy. */ writer.println(ident(3) + "int batchSize = iterationParams.getBatchSize();"); writer.println(ident(3) + "int opsPerInv = benchmarkParams.getOpsPerInvocation();"); writer.println(ident(3) + "res.allOps *= opsPerInv;"); writer.println(ident(3) + "res.allOps /= batchSize;"); writer.println(ident(3) + "res.measuredOps *= opsPerInv;"); writer.println(ident(3) + "res.measuredOps /= batchSize;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);"); if (isSingleMethod) { writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } else { writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } addAuxCounters(writer, "ThroughputResult", states, method); methodEpilog(writer); writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); } writer.println(ident(3) + "throw new IllegalStateException(\"Harness failed to distribute threads among groups properly\");"); writer.println(ident(1) + "}"); writer.println(); // measurement loop bodies for (MethodInfo method : methodGroup.methods()) { String methodName = method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX; compilerControl.defaultForceInline(method); writer.println(ident(1) + "public static" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + "(" + getStubTypeArgs() + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); writer.println(ident(2) + "long operations = 0;"); writer.println(ident(2) + "long realTime = 0;"); writer.println(ident(2) + "result.startTime = System.nanoTime();"); writer.println(ident(2) + "do {"); invocationProlog(writer, 3, method, states, true); writer.println(ident(3) + emitCall(method, states) + ';'); invocationEpilog(writer, 3, method, states, true); writer.println(ident(3) + "operations++;"); writer.println(ident(2) + "} while(!control.isDone);"); writer.println(ident(2) + "result.stopTime = System.nanoTime();"); writer.println(ident(2) + "result.realTime = realTime;"); writer.println(ident(2) + "result.measuredOps = operations;"); writer.println(ident(1) + "}"); writer.println(); } } private void addAuxCounters(PrintWriter writer, String resName, StateObjectHandler states, MethodInfo method) { for (String res : states.getAuxResults(method, resName)) { writer.println(ident(3) + "results.add(" + res + ");"); } } private void generateAverageTime(PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { writer.println(ident(1) + "public BenchmarkTaskResult " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {"); methodProlog(writer); boolean isSingleMethod = (methodGroup.methods().size() == 1); int subGroup = -1; for (MethodInfo method : methodGroup.methods()) { subGroup++; writer.println(ident(2) + "if (threadParams.getSubgroupIndex() == " + subGroup + ") {"); writer.println(ident(3) + "RawResults res = new RawResults();"); iterationProlog(writer, 3, method, states); // synchronize iterations prolog: announce ready writer.println(ident(3) + "control.announceWarmupReady();"); // synchronize iterations prolog: catchup loop writer.println(ident(3) + "while (control.warmupShouldWait) {"); invocationProlog(writer, 4, method, states, false); writer.println(ident(4) + emitCall(method, states) + ';'); invocationEpilog(writer, 4, method, states, false); writer.println(ident(4) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(4) + "res.allOps++;"); writer.println(ident(3) + "}"); writer.println(); // control objects get a special treatment writer.println(ident(3) + "notifyControl.startMeasurement = true;"); // measurement loop call writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + "(" + getStubArgs() + prefix(states.getArgList(method)) + ");"); // control objects get a special treatment writer.println(ident(3) + "notifyControl.stopMeasurement = true;"); // synchronize iterations epilog: announce ready writer.println(ident(3) + "control.announceWarmdownReady();"); // synchronize iterations epilog: catchup loop writer.println(ident(3) + "try {"); writer.println(ident(4) + "while (control.warmdownShouldWait) {"); invocationProlog(writer, 5, method, states, false); writer.println(ident(5) + emitCall(method, states) + ';'); invocationEpilog(writer, 5, method, states, false); writer.println(ident(5) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(5) + "res.allOps++;"); writer.println(ident(4) + "}"); writer.println(ident(3) + "} catch (Throwable e) {"); writer.println(ident(4) + "if (!(e instanceof InterruptedException)) throw e;"); writer.println(ident(3) + "}"); writer.println(ident(3) + "control.preTearDown();"); iterationEpilog(writer, 3, method, states); writer.println(ident(3) + "res.allOps += res.measuredOps;"); /* Adjust the operation counts: 1) res.measuredOps counted the individual @Benchmark invocations. Therefore, we need to adjust for opsPerInv (pretending each @Benchmark invocation counts as $opsPerInv ops); and we need to adjust down for $batchSize (pretending we had the batched run, and $batchSize @Benchmark invocations counted as single op) 2) res.measuredOps counted the individual @Benchmark invocations as well; the same reasoning applies. It's prudent to make the multiplication first to get more accuracy. */ writer.println(ident(3) + "int batchSize = iterationParams.getBatchSize();"); writer.println(ident(3) + "int opsPerInv = benchmarkParams.getOpsPerInvocation();"); writer.println(ident(3) + "res.allOps *= opsPerInv;"); writer.println(ident(3) + "res.allOps /= batchSize;"); writer.println(ident(3) + "res.measuredOps *= opsPerInv;"); writer.println(ident(3) + "res.measuredOps /= batchSize;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);"); if (isSingleMethod) { writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } else { writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } addAuxCounters(writer, "AverageTimeResult", states, method); methodEpilog(writer); writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); } writer.println(ident(3) + "throw new IllegalStateException(\"Harness failed to distribute threads among groups properly\");"); writer.println(ident(1) + "}"); writer.println(); // measurement loop bodies for (MethodInfo method : methodGroup.methods()) { String methodName = method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX; compilerControl.defaultForceInline(method); writer.println(ident(1) + "public static" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + "(" + getStubTypeArgs() + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); writer.println(ident(2) + "long operations = 0;"); writer.println(ident(2) + "long realTime = 0;"); writer.println(ident(2) + "result.startTime = System.nanoTime();"); writer.println(ident(2) + "do {"); invocationProlog(writer, 3, method, states, true); writer.println(ident(3) + emitCall(method, states) + ';'); invocationEpilog(writer, 3, method, states, true); writer.println(ident(3) + "operations++;"); writer.println(ident(2) + "} while(!control.isDone);"); writer.println(ident(2) + "result.stopTime = System.nanoTime();"); writer.println(ident(2) + "result.realTime = realTime;"); writer.println(ident(2) + "result.measuredOps = operations;"); writer.println(ident(1) + "}"); writer.println(); } } private String getStubArgs() { return "control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask"; } private String getStubTypeArgs() { return "InfraControl control, RawResults result, " + "BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, " + "Blackhole blackhole, Control notifyControl, int startRndMask"; } private void methodProlog(PrintWriter writer) { // do nothing writer.println(ident(2) + "this.benchmarkParams = control.benchmarkParams;"); writer.println(ident(2) + "this.iterationParams = control.iterationParams;"); writer.println(ident(2) + "this.threadParams = threadParams;"); writer.println(ident(2) + "this.notifyControl = control.notifyControl;"); writer.println(ident(2) + "if (this.blackhole == null) {"); writer.println(ident(3) + "this.blackhole = new Blackhole(\"Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.\");"); writer.println(ident(2) + "}"); } private void methodEpilog(PrintWriter writer) { writer.println(ident(3) + "this.blackhole.evaporate(\"Yes, I am Stephen Hawking, and know a thing or two about black holes.\");"); } private String prefix(String argList) { if (argList.trim().isEmpty()) { return ""; } else { return ", " + argList; } } private void generateSampleTime(PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { writer.println(ident(1) + "public BenchmarkTaskResult " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {"); methodProlog(writer); boolean isSingleMethod = (methodGroup.methods().size() == 1); int subGroup = -1; for (MethodInfo method : methodGroup.methods()) { subGroup++; writer.println(ident(2) + "if (threadParams.getSubgroupIndex() == " + subGroup + ") {"); writer.println(ident(3) + "RawResults res = new RawResults();"); iterationProlog(writer, 3, method, states); // synchronize iterations prolog: announce ready writer.println(ident(3) + "control.announceWarmupReady();"); // synchronize iterations prolog: catchup loop writer.println(ident(3) + "while (control.warmupShouldWait) {"); invocationProlog(writer, 4, method, states, false); writer.println(ident(4) + emitCall(method, states) + ';'); invocationEpilog(writer, 4, method, states, false); writer.println(ident(4) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(4) + "res.allOps++;"); writer.println(ident(3) + "}"); writer.println(); // control objects get a special treatment writer.println(ident(3) + "notifyControl.startMeasurement = true;"); // measurement loop call writer.println(ident(3) + "int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20); // at max, 20 timestamps per millisecond"); writer.println(ident(3) + "int batchSize = iterationParams.getBatchSize();"); writer.println(ident(3) + "int opsPerInv = benchmarkParams.getOpsPerInvocation();"); writer.println(ident(3) + "SampleBuffer buffer = new SampleBuffer();"); writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + "(" + getStubArgs() + ", buffer, targetSamples, opsPerInv, batchSize" + prefix(states.getArgList(method)) + ");"); // control objects get a special treatment writer.println(ident(3) + "notifyControl.stopMeasurement = true;"); // synchronize iterations epilog: announce ready writer.println(ident(3) + "control.announceWarmdownReady();"); // synchronize iterations epilog: catchup loop writer.println(ident(3) + "try {"); writer.println(ident(4) + "while (control.warmdownShouldWait) {"); invocationProlog(writer, 5, method, states, false); writer.println(ident(5) + emitCall(method, states) + ';'); invocationEpilog(writer, 5, method, states, false); writer.println(ident(5) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(5) + "res.allOps++;"); writer.println(ident(4) + "}"); writer.println(ident(3) + "} catch (Throwable e) {"); writer.println(ident(4) + "if (!(e instanceof InterruptedException)) throw e;"); writer.println(ident(3) + "}"); writer.println(ident(3) + "control.preTearDown();"); iterationEpilog(writer, 3, method, states); /* Adjust the operation counts: 1) res.measuredOps counted the batched @Benchmark invocations. Therefore, we need only to adjust for opsPerInv (pretending each @Benchmark invocation counts as $opsPerInv ops); 2) res.allOps counted the individual @Benchmark invocations; to it needs the adjustment for $batchSize. It's prudent to make the multiplication first to get more accuracy. */ writer.println(ident(3) + "res.allOps += res.measuredOps * batchSize;"); writer.println(ident(3) + "res.allOps *= opsPerInv;"); writer.println(ident(3) + "res.allOps /= batchSize;"); writer.println(ident(3) + "res.measuredOps *= opsPerInv;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);"); if (isSingleMethod) { writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); } else { writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); } addAuxCounters(writer, "SampleTimeResult", states, method); methodEpilog(writer); writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); } writer.println(ident(3) + "throw new IllegalStateException(\"Harness failed to distribute threads among groups properly\");"); writer.println(ident(1) + "}"); writer.println(); // measurement loop bodies for (MethodInfo method : methodGroup.methods()) { String methodName = method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX; compilerControl.defaultForceInline(method); writer.println(ident(1) + "public static" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + "(" + getStubTypeArgs() + ", SampleBuffer buffer, int targetSamples, long opsPerInv, int batchSize" + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); writer.println(ident(2) + "long realTime = 0;"); writer.println(ident(2) + "long operations = 0;"); writer.println(ident(2) + "int rnd = (int)System.nanoTime();"); writer.println(ident(2) + "int rndMask = startRndMask;"); writer.println(ident(2) + "long time = 0;"); writer.println(ident(2) + "int currentStride = 0;"); writer.println(ident(2) + "do {"); invocationProlog(writer, 3, method, states, true); writer.println(ident(3) + "rnd = (rnd * 1664525 + 1013904223);"); writer.println(ident(3) + "boolean sample = (rnd & rndMask) == 0;"); writer.println(ident(3) + "if (sample) {"); writer.println(ident(4) + "time = System.nanoTime();"); writer.println(ident(3) + "}"); writer.println(ident(3) + "for (int b = 0; b < batchSize; b++) {"); writer.println(ident(4) + "if (control.volatileSpoiler) return;"); writer.println(ident(4) + "" + emitCall(method, states) + ';'); writer.println(ident(3) + "}"); writer.println(ident(3) + "if (sample) {"); writer.println(ident(4) + "buffer.add((System.nanoTime() - time) / opsPerInv);"); writer.println(ident(4) + "if (currentStride++ > targetSamples) {"); writer.println(ident(5) + "buffer.half();"); writer.println(ident(5) + "currentStride = 0;"); writer.println(ident(5) + "rndMask = (rndMask << 1) + 1;"); writer.println(ident(4) + "}"); writer.println(ident(3) + "}"); invocationEpilog(writer, 3, method, states, true); writer.println(ident(3) + "operations++;"); writer.println(ident(2) + "} while(!control.isDone);"); writer.println(ident(2) + "startRndMask = Math.max(startRndMask, rndMask);"); writer.println(ident(2) + "result.realTime = realTime;"); writer.println(ident(2) + "result.measuredOps = operations;"); writer.println(ident(1) + "}"); writer.println(); } } private void generateSingleShotTime(PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { writer.println(ident(1) + "public BenchmarkTaskResult " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {"); methodProlog(writer); boolean isSingleMethod = (methodGroup.methods().size() == 1); int subGroup = -1; for (MethodInfo method : methodGroup.methods()) { compilerControl.defaultForceInline(method); subGroup++; writer.println(ident(2) + "if (threadParams.getSubgroupIndex() == " + subGroup + ") {"); iterationProlog(writer, 3, method, states); // control objects get a special treatment writer.println(ident(3) + "notifyControl.startMeasurement = true;"); // measurement loop call writer.println(ident(3) + "RawResults res = new RawResults();"); writer.println(ident(3) + "int batchSize = iterationParams.getBatchSize();"); writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + "(" + getStubArgs() + ", batchSize" + prefix(states.getArgList(method)) + ");"); writer.println(ident(3) + "control.preTearDown();"); iterationEpilog(writer, 3, method, states); /* * Adjust total ops: * Single shot always does single op. Therefore, we need to adjust for $opsPerInv (pretending each @Benchmark * invocation counts as $opsPerInv ops). We *don't need* to adjust down for $batchSize, because we always have * one "op". */ writer.println(ident(3) + "int opsPerInv = control.benchmarkParams.getOpsPerInvocation();"); writer.println(ident(3) + "long totalOps = opsPerInv;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);"); if (isSingleMethod) { writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.getTime(), totalOps, benchmarkParams.getTimeUnit()));"); } else { writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", res.getTime(), totalOps, benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.getTime(), totalOps, benchmarkParams.getTimeUnit()));"); } addAuxCounters(writer, "SingleShotResult", states, method); methodEpilog(writer); writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); } writer.println(ident(3) + "throw new IllegalStateException(\"Harness failed to distribute threads among groups properly\");"); writer.println(ident(1) + "}"); writer.println(); // measurement stub bodies for (MethodInfo method : methodGroup.methods()) { String methodName = method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX; compilerControl.defaultForceInline(method); writer.println(ident(1) + "public static" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + "(" + getStubTypeArgs() + ", int batchSize" + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); writer.println(ident(2) + "long realTime = 0;"); writer.println(ident(2) + "result.startTime = System.nanoTime();"); writer.println(ident(2) + "for (int b = 0; b < batchSize; b++) {"); writer.println(ident(3) + "if (control.volatileSpoiler) return;"); invocationProlog(writer, 3, method, states, true); writer.println(ident(3) + emitCall(method, states) + ';'); invocationEpilog(writer, 3, method, states, true); writer.println(ident(2) + "}"); writer.println(ident(2) + "result.stopTime = System.nanoTime();"); writer.println(ident(2) + "result.realTime = realTime;"); writer.println(ident(1) + "}"); writer.println(); } } private void invocationProlog(PrintWriter writer, int prefix, MethodInfo method, StateObjectHandler states, boolean pauseMeasurement) { if (states.hasInvocationStubs(method)) { for (String s : states.getInvocationSetups(method)) writer.println(ident(prefix) + s); if (pauseMeasurement) writer.println(ident(prefix) + "long rt = System.nanoTime();"); } } private void invocationEpilog(PrintWriter writer, int prefix, MethodInfo method, StateObjectHandler states, boolean pauseMeasurement) { if (states.hasInvocationStubs(method)) { if (pauseMeasurement) writer.println(ident(prefix) + "realTime += (System.nanoTime() - rt);"); for (String s : states.getInvocationTearDowns(method)) writer.println(ident(prefix) + s); } } private void iterationProlog(PrintWriter writer, int prefix, MethodInfo method, StateObjectHandler states) { for (String s : states.getStateGetters(method)) writer.println(ident(prefix) + s); writer.println(); writer.println(ident(prefix) + "control.preSetup();"); for (String s : states.getIterationSetups(method)) writer.println(ident(prefix) + s); writer.println(); // reset @AuxCounters for (String s : states.getAuxResets(method)) writer.println(ident(prefix) + s); writer.println(); } private void iterationEpilog(PrintWriter writer, int prefix, MethodInfo method, StateObjectHandler states) { for (String s : states.getIterationTearDowns(method)) writer.println(ident(prefix) + s); writer.println(); writer.println(ident(prefix) + "if (control.isLastIteration()) {"); for (String s : states.getRunTearDowns(method)) writer.println(ident(prefix + 1) + s); for (String s : states.getStateDestructors(method)) writer.println(ident(prefix + 1) + s); writer.println(ident(prefix) + "}"); } private String emitCall(MethodInfo method, StateObjectHandler states) { if ("void".equalsIgnoreCase(method.getReturnType())) { return states.getImplicit("bench").localIdentifier + "." + method.getName() + "(" + states.getBenchmarkArgList(method) + ")"; } else { return "blackhole.consume(" + states.getImplicit("bench").localIdentifier + "." + method.getName() + "(" + states.getBenchmarkArgList(method) + "))"; } } static volatile String[] INDENTS; static final Object INDENTS_LOCK = new Object(); static String ident(int tabs) { String[] is = INDENTS; if (is == null || tabs >= is.length) { synchronized (INDENTS_LOCK) { is = INDENTS; if (is == null || tabs >= is.length) { final int TAB_SIZE = 4; is = new String[tabs + 1]; for (int p = 0; p <= tabs; p++) { char[] cs = new char[p * TAB_SIZE]; Arrays.fill(cs, ' '); is[p] = new String(cs); } INDENTS = is; } } } return is[tabs]; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorSession.java000066400000000000000000000026131446271450100324400ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import java.util.HashSet; import java.util.Set; public class BenchmarkGeneratorSession { public final Set generatedStateOverrides = new HashSet<>(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java000066400000000000000000000267751446271450100321340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.OperationsPerInvocation; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; class BenchmarkGeneratorUtils { private static final Collection> JMH_ANNOTATIONS; private static final Multimap, ElementType> JMH_ANNOTATION_TARGETS; static { JMH_ANNOTATIONS = Arrays.asList( AuxCounters.class, BenchmarkMode.class, CompilerControl.class, Fork.class, Benchmark.class, Group.class, GroupThreads.class, Measurement.class, OperationsPerInvocation.class, OutputTimeUnit.class, Param.class, Setup.class, State.class, TearDown.class, Threads.class, Warmup.class ); JMH_ANNOTATION_TARGETS = new HashMultimap<>(); for (Class ann : JMH_ANNOTATIONS) { Target target = ann.getAnnotation(Target.class); if (target != null) { ElementType[] types = target.value(); for (ElementType type : types) { JMH_ANNOTATION_TARGETS.put(ann, type); } } } } public static boolean checkJavaIdentifier(String id) { for (int i = 0; i < id.length(); i++) { char c = id.charAt(i); if (!Character.isJavaIdentifierPart(c)) { return false; } } return true; } public static Collection getMethodsAnnotatedWith(GeneratorSource source, Class annClass) { List mis = new ArrayList<>(); for (ClassInfo ci : source.getClasses()) { for (MethodInfo mi : ci.getMethods()) { if (mi.getAnnotation(annClass) != null) { mis.add(mi); } } } return mis; } public static Collection getClassesAnnotatedWith(GeneratorSource source, Class annClass) { List cis = new ArrayList<>(); for (ClassInfo ci : source.getClasses()) { if (ci.getAnnotation(annClass) != null) { cis.add(ci); } } return cis; } public static Collection getFieldsAnnotatedWith(GeneratorSource source, Class annClass) { List mis = new ArrayList<>(); for (ClassInfo ci : source.getClasses()) { for (FieldInfo mi : ci.getFields()) { if (mi.getAnnotation(annClass) != null) { mis.add(mi); } } } return mis; } public static Collection getAllFields(ClassInfo ci) { List ls = new ArrayList<>(); do { ls.addAll(ci.getFields()); } while ((ci = ci.getSuperClass()) != null); return ls; } public static Collection getAllMethods(ClassInfo ci) { List ls = new ArrayList<>(); do { ls.addAll(ci.getMethods()); } while ((ci = ci.getSuperClass()) != null); return ls; } public static T getAnnSuper(ClassInfo ci, Class annClass) { T ann = ci.getAnnotation(annClass); if (ann != null) { return ann; } else { ClassInfo eci = ci.getSuperClass(); if (eci != null) { return getAnnSuper(eci, annClass); } } return null; } public static T getAnnSyntax(ClassInfo ci, Class annClass) { T ann = ci.getAnnotation(annClass); if (ann != null) { return ann; } else { ClassInfo eci = ci.getDeclaringClass(); if (eci != null) { return getAnnSyntax(eci, annClass); } } return null; } public static T getAnnSyntax(MethodInfo mi, Class annClass) { T ann = mi.getAnnotation(annClass); if (ann != null) { return ann; } else { return getAnnSyntax(mi.getDeclaringClass(), annClass); } } public static T getAnnSuper(MethodInfo mi, Class annClass) { T ann = mi.getAnnotation(annClass); if (ann != null) { return ann; } else { return getAnnSuper(mi.getDeclaringClass(), annClass); } } public static T getAnnSuper(MethodInfo mi, ClassInfo startCi, Class annClass) { T ann = mi.getAnnotation(annClass); if (ann != null) { return ann; } else { return getAnnSuper(startCi, annClass); } } public static Collection getAnnSuperAll(MethodInfo mi, ClassInfo startCi, Class annClass) { Collection results = new ArrayList<>(); { T ann = mi.getAnnotation(annClass); if (ann != null) { results.add(ann); } } ClassInfo ci = startCi; do { T ann = ci.getAnnotation(annClass); if (ann != null) { results.add(ann); } ci = ci.getSuperClass(); } while (ci != null); return results; } public static String getGeneratedName(ClassInfo ci) { String name = ""; do { name = ci.getName() + (name.isEmpty() ? "" : "_" + name); } while ((ci = ci.getDeclaringClass()) != null); return name; } public static String getNestedNames(ClassInfo ci) { String name = ""; do { name = ci.getName() + (name.isEmpty() ? "" : "$" + name); } while ((ci = ci.getDeclaringClass()) != null); return name; } public static void checkAnnotations(FieldInfo fi) { for (Class ann : JMH_ANNOTATIONS) { if (fi.getAnnotation(ann) != null && !JMH_ANNOTATION_TARGETS.get(ann).contains(ElementType.FIELD)) { throw new GenerationException( "Annotation @" + ann.getSimpleName() + " is not applicable to fields.", fi); } } } public static void checkAnnotations(ClassInfo ci) { for (Class ann : JMH_ANNOTATIONS) { if (ci.getAnnotation(ann) != null && !JMH_ANNOTATION_TARGETS.get(ann).contains(ElementType.TYPE)) { throw new GenerationException( "Annotation @" + ann.getSimpleName() + " is not applicable to types.", ci); } } } public static void checkAnnotations(MethodInfo mi) { for (Class ann : JMH_ANNOTATIONS) { if (mi.getAnnotation(ann) != null && !JMH_ANNOTATION_TARGETS.get(ann).contains(ElementType.METHOD)) { throw new GenerationException( "Annotation @" + ann.getSimpleName() + " is not applicable to methods.", mi); } } } /** *

Gets the parameter values to be used for this field. In most cases this will be the values declared * in the {@code @Param} annotation.

* *

For an enum field type, an empty parameter list will be resolved to be the full list of enum constants * of that type.

* * @param fi type of the field for which to find parameters * @return string values representing the actual parameters */ private static String[] toParameterValues(FieldInfo fi) { String[] annotatedValues = fi.getAnnotation(Param.class).value(); boolean isBlankEnum = (annotatedValues.length == 1) && Param.BLANK_ARGS.equals(annotatedValues[0]) && fi.getType().isEnum(); if (isBlankEnum) { Collection enumConstants = fi.getType().getEnumConstants(); if (enumConstants.isEmpty()) { throw new GenerationException("Enum type of field had no constants. " + "Declare some constants or remove the @" + Param.class.getSimpleName() + ".", fi); } return enumConstants.toArray(new String[0]); } else { return annotatedValues; } } /** * Compute the parameter space given by {@code @Param} annotations and add all them to the group. * * @param host type of the state {@code @State} in which to find {@code @Param}s * @param group method group */ static void addParameterValuesToGroup(ClassInfo host, MethodGroup group) { // Add all inherited @Param fields for (FieldInfo fi : getAllFields(host)) { if (fi.getAnnotation(Param.class) != null) { String[] values = toParameterValues(fi); group.addParamValues(fi.getName(), values); } } // Add all @Param fields reachable through the dependencies. // This recursive approach always converges because @State dependency graph is DAG. for (MethodInfo mi : getAllMethods(host)) { if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) { for (ParameterInfo pi : mi.getParameters()) { addParameterValuesToGroup(pi.getType(), group); } } } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkInfo.java000066400000000000000000000046351446271450100300470ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; class BenchmarkInfo { public final String userClassQName; public final String generatedClassQName; public final String generatedPackageName; public final String generatedClassName; public final MethodGroup methodGroup; public BenchmarkInfo(String userClassQName, String generatedPackageName, String generatedClassName, MethodGroup methodGroup) { this.userClassQName = userClassQName; this.generatedPackageName = generatedPackageName; this.generatedClassName = generatedClassName; this.generatedClassQName = generatedPackageName + "." + generatedClassName; this.methodGroup = methodGroup; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; BenchmarkInfo that = (BenchmarkInfo) o; if (!methodGroup.equals(that.methodGroup)) return false; if (!userClassQName.equals(that.userClassQName)) return false; return true; } @Override public int hashCode() { int result = userClassQName.hashCode(); result = 31 * result + methodGroup.hashCode(); return result; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/ClassInfo.java000066400000000000000000000057771446271450100272320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import java.lang.annotation.Annotation; import java.util.Collection; /** * Class metadata. */ public interface ClassInfo extends MetadataInfo { /** * @return fully qualified package name */ String getPackageName(); /** * * @return fully qualified class name */ String getQualifiedName(); /** * @return short class name */ String getName(); /** * @return reference to super-class metadata */ ClassInfo getSuperClass(); /** * @return reference to syntactically-enclosing class */ ClassInfo getDeclaringClass(); /** * @return collection of all fields in class */ Collection getFields(); /** * @return collection of all methods in class */ Collection getMethods(); /** * @return collection of all constructors in class */ Collection getConstructors(); /** * @param annClass annotation class * @param annotation type * @return class-level annotation, if any; null otherwise */ T getAnnotation(Class annClass); /** * @return true, if class is abstract */ boolean isAbstract(); /** * @return true, if class is abstract */ boolean isPublic(); /** * @return true, if class is strictfp */ boolean isStrictFP(); /** * @return true, if class is final */ boolean isFinal(); /** * @return true, if class is inner */ boolean isInner(); /** * @return true, if class is enum */ boolean isEnum(); /** * @return if class is enum, the collection of its constant values; * empty collection otherwise */ Collection getEnumConstants(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java000066400000000000000000000121441446271450100316250ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.runner.CompilerHints; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.Comparator; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; class CompilerControlPlugin { private final SortedSet lines = new TreeSet<>(); private final Set defaultForceInlineMethods = new TreeSet<>(Comparator.comparing(MethodInfo::getQualifiedName)); private final Set alwaysDontInlineMethods = new TreeSet<>(); public void defaultForceInline(MethodInfo methodInfo) { defaultForceInlineMethods.add(methodInfo); } public void alwaysDontInline(String className, String methodName) { alwaysDontInlineMethods.add(getName(className, methodName)); } public void process(GeneratorSource source, GeneratorDestination destination) { try { for (MethodInfo element : BenchmarkGeneratorUtils.getMethodsAnnotatedWith(source, CompilerControl.class)) { CompilerControl ann = element.getAnnotation(CompilerControl.class); if (ann == null) { throw new IllegalStateException("No annotation"); } CompilerControl.Mode command = ann.value(); lines.add(command.command() + "," + getName(element)); } for (MethodInfo element : defaultForceInlineMethods) { // Skip methods annotated explicitly if (element.getAnnotation(CompilerControl.class) != null) continue; // Skip methods in classes that are annotated explicitly if (element.getDeclaringClass().getAnnotation(CompilerControl.class) != null) continue; lines.add(CompilerControl.Mode.INLINE.command() + "," + getName(element)); } for (String element : alwaysDontInlineMethods) { lines.add(CompilerControl.Mode.DONT_INLINE.command() + "," + element); } for (ClassInfo element : BenchmarkGeneratorUtils.getClassesAnnotatedWith(source, CompilerControl.class)) { CompilerControl ann = element.getAnnotation(CompilerControl.class); if (ann == null) { throw new IllegalStateException("No annotation"); } CompilerControl.Mode command = ann.value(); lines.add(command.command() + "," + getName(element)); } } catch (Throwable t) { destination.printError("Compiler control generators had thrown the unexpected exception", t); } } public void finish(GeneratorSource source, GeneratorDestination destination) { try (Writer w = new OutputStreamWriter(destination.newResource(CompilerHints.LIST.substring(1)), StandardCharsets.UTF_8)){ PrintWriter writer = new PrintWriter(w); for (String line : lines) { writer.println(line); } writer.close(); } catch (IOException ex) { destination.printError("Error writing compiler hint list ", ex); } catch (Throwable t) { destination.printError("Compiler control generators had thrown the unexpected exception", t); } } private static String getName(String className, String methodName) { return className.replaceAll("\\.", "/") + "." + methodName; } private static String getName(MethodInfo mi) { return getName(getClassName(mi.getDeclaringClass()), mi.getName()); } private static String getName(ClassInfo ci) { return getName(getClassName(ci), "*"); } private static String getClassName(ClassInfo ci) { return ci.getPackageName() + "." + BenchmarkGeneratorUtils.getNestedNames(ci); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FieldInfo.java000066400000000000000000000040601446271450100271700ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import java.lang.annotation.Annotation; /** * Field metadata info. */ public interface FieldInfo extends MetadataInfo { /** * @return field name */ String getName(); /** * @return fully qualified field type */ ClassInfo getType(); /** * @return reference to syntactically-enclosing class */ ClassInfo getDeclaringClass(); /** * @param annClass annotation class * @param annotation type * @return field-level annotation, if any; null otherwise */ T getAnnotation(Class annClass); /** * @return true, if field is public */ boolean isPublic(); /** * @return true, if field is static */ boolean isStatic(); /** * @return true, if field is final */ boolean isFinal(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java000066400000000000000000000106441446271450100316240ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import java.io.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; public class FileSystemDestination implements GeneratorDestination { private final File resourceDir; private final File sourceDir; private final List sourceErrors; private final List sourceWarnings; public FileSystemDestination(File resourceDir, File sourceDir) { this.resourceDir = resourceDir; this.sourceDir = sourceDir; this.sourceErrors = new ArrayList<>(); this.sourceWarnings = new ArrayList<>(); } @Override public OutputStream newResource(String resourcePath) throws IOException { String pathName = resourceDir.getAbsolutePath() + "/" + resourcePath; File p = new File(pathName.substring(0, pathName.lastIndexOf("/"))); if (!p.mkdirs() && !p.isDirectory()) { throw new IOException("Unable to create " + p.getAbsolutePath()); } return new FileOutputStream(new File(pathName)); } @Override public InputStream getResource(String resourcePath) throws IOException { String pathName = resourceDir.getAbsolutePath() + "/" + resourcePath; File p = new File(pathName.substring(0, pathName.lastIndexOf("/"))); if (!p.isFile() && !p.exists()) { throw new IOException("Unable to open " + pathName); } return new FileInputStream(new File(pathName)); } @Override public Writer newClass(String className, String originatingClassName) throws IOException { String pathName = sourceDir.getAbsolutePath() + "/" + className.replaceAll("\\.", "/"); File p = new File(pathName.substring(0, pathName.lastIndexOf("/"))); if (!p.mkdirs() && !p.isDirectory()) { throw new IOException("Unable to create " + p.getAbsolutePath()); } return new FileWriter(new File(pathName + ".java")); } @Override public void printError(String message) { sourceErrors.add(new SourceError(message)); } @Override public void printError(String message, MetadataInfo element) { sourceErrors.add(new SourceElementError(message, element)); } @Override public void printError(String message, Throwable throwable) { sourceErrors.add(new SourceThrowableError(message, throwable)); } public boolean hasErrors() { return !sourceErrors.isEmpty(); } public Collection getErrors() { return sourceErrors; } @Override public void printWarning(String message) { sourceWarnings.add(new SourceWarning(message)); } @Override public void printWarning(String message, MetadataInfo element) { sourceWarnings.add(new SourceElementWarning(message, element)); } @Override public void printWarning(String message, Throwable throwable) { sourceWarnings.add(new SourceThrowableWarning(message, throwable)); } public boolean hasWarnings() { return !sourceWarnings.isEmpty(); } public Collection getWarnings() { return sourceWarnings; } @Override public void printNote(String message) { // do nothing } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/GenerationException.java000066400000000000000000000031421446271450100313030ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; public class GenerationException extends RuntimeException { private static final long serialVersionUID = -3462499052514960496L; private final MetadataInfo element; public GenerationException(String message, MetadataInfo element) { super(message); this.element = element; } public MetadataInfo getElement() { return element; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/GeneratorDestination.java000066400000000000000000000100651446271450100314630ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import java.io.*; /** * Generator destination. * *

The exit point for {@link org.openjdk.jmh.generators.core.BenchmarkGenerator}.

*/ public interface GeneratorDestination { /** * Returns the stream for the given resource. * Callers are responsible for closing streams. * * @param resourcePath resource path * @return output stream to write the resource to. * @throws java.io.IOException if something wacked happens */ OutputStream newResource(String resourcePath) throws IOException; /** * Returns the stream for the given resource. * Callers are responsible for closing streams. * * @param resourcePath resource path * @return stream usable to read the resource * @throws java.io.IOException if something wacked happens */ InputStream getResource(String resourcePath) throws IOException; /** * Returns the Writer for the given class. * Callers are responsible for closing Writers. * * @param className class name * @param originatingClassName class name causing the creation of this class * @return writer usable to write the resource * @throws IOException if something wacked happens */ Writer newClass(String className, String originatingClassName) throws IOException; /** * Print the error. * Calling this method should not terminate anything. * * @param message error. */ void printError(String message); /** * Print the error. * Calling this method should not terminate anything. * * @param message error. * @param element metadata element, to which this error is tailored */ void printError(String message, MetadataInfo element); /** * Print the error. * Calling this method should not terminate anything. * * @param message error. * @param throwable exception causing the error */ void printError(String message, Throwable throwable); /** * Print the warning. * Calling this method should not terminate anything. * * @param message warning. */ void printWarning(String message); /** * Print the warning. * Calling this method should not terminate anything. * * @param message warning. * @param element metadata element, to which this error is tailored */ void printWarning(String message, MetadataInfo element); /** * Print the warning. * Calling this method should not terminate anything. * * @param message warning. * @param throwable exception causing the error */ void printWarning(String message, Throwable throwable); /** * Print the informative message. * Calling this method should not terminate anything. * * @param message message. */ void printNote(String message); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/GeneratorSource.java000066400000000000000000000035711446271450100304460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import java.util.Collection; /** * Generator source. *

The entry point for {@link org.openjdk.jmh.generators.core.BenchmarkGenerator}.

*/ public interface GeneratorSource { /** * @return collection of all resolved classes */ Collection getClasses(); /** * Resolve class info for a name. * *

Users may call this method for the classes not * listed in {@link #getClasses()} call, the implementation * has to have the fall-back strategy for these cases.

* * @param className class name * @return class metainfo */ ClassInfo resolveClass(String className); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/HelperMethodInvocation.java000066400000000000000000000050551446271450100317500ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.Level; class HelperMethodInvocation implements Comparable { public final MethodInfo method; public final StateObject state; public final Level helperLevel; public final HelperType type; public HelperMethodInvocation(MethodInfo method, StateObject state, Level helperLevel, HelperType type) { this.method = method; this.state = state; this.helperLevel = helperLevel; this.type = type; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; HelperMethodInvocation that = (HelperMethodInvocation) o; if (helperLevel != that.helperLevel) return false; if (!method.equals(that.method)) return false; if (!state.equals(that.state)) return false; if (type != that.type) return false; return true; } @Override public int hashCode() { int result = method.hashCode(); result = 31 * result + state.hashCode(); result = 31 * result + helperLevel.hashCode(); result = 31 * result + type.hashCode(); return result; } @Override public int compareTo(HelperMethodInvocation o) { return method.compareTo(o.method); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/HelperType.java000066400000000000000000000024241446271450100274140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; enum HelperType { SETUP, TEARDOWN, } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Identifiers.java000066400000000000000000000055401446271450100276020ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.Scope; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; class Identifiers { private final Map collapsedTypes = new HashMap<>(); private int collapsedIndex = 0; private final Set claimedJmhTypes = new HashSet<>(); private final Map jmhTypes = new HashMap<>(); public String getJMHtype(ClassInfo type) { String id = BenchmarkGeneratorUtils.getGeneratedName(type); String jmhType = jmhTypes.get(id); if (jmhType == null) { int v = 0; do { jmhType = id + (v == 0 ? "" : "_" + v) + "_jmhType"; v++; } while (!claimedJmhTypes.add(jmhType)); jmhTypes.put(id, jmhType); } return jmhType; } public String collapseTypeName(String e) { if (collapsedTypes.containsKey(e)) { return collapsedTypes.get(e); } String[] strings = e.split("\\."); String name = strings[strings.length - 1].toLowerCase(); String collapsedName = name + (collapsedIndex++) + "_"; collapsedTypes.put(e, collapsedName); return collapsedName; } private int index = 0; public String identifier(Scope scope) { switch (scope) { case Benchmark: case Group: { return "G"; } case Thread: { return String.valueOf(index++); } default: throw new GenerationException("Unknown scope: " + scope, null); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MetadataInfo.java000066400000000000000000000024771446271450100276770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; /** * Super-interface for all metadata elements. */ public interface MetadataInfo { } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java000066400000000000000000000234621446271450100275750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Optional; import java.lang.annotation.Annotation; import java.util.*; import java.util.concurrent.TimeUnit; class MethodGroup implements Comparable { private final ClassInfo ci; private final String name; private final Set methods; private final EnumSet modes; private final Map params; private boolean strictFP; public MethodGroup(ClassInfo ci, String name) { this.ci = ci; this.name = name; this.methods = new TreeSet<>(); this.modes = EnumSet.noneOf(Mode.class); this.params = new TreeMap<>(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MethodGroup methodGroup = (MethodGroup) o; if (!name.equals(methodGroup.name)) return false; return true; } @Override public int hashCode() { return name.hashCode(); } @Override public int compareTo(MethodGroup o) { return name.compareTo(o.name); } public void addMethod(MethodInfo method, int threads) { MethodInvocation mi = new MethodInvocation(method, threads); if (!methods.add(mi)) { throw new GenerationException( "Duplicate @" + Benchmark.class.getSimpleName() + " method name: " + mi.method.getQualifiedName() + ". JMH needs an uniquely named method, regardless of the arguments list. ", method); } } public Collection methods() { Collection result = new ArrayList<>(); for (MethodInvocation m : methods) { result.add(m.method); } return result; } public Optional getTotalThreadCount() { for (Threads ann : getAll(Threads.class)) { return Optional.of(ann.value()); } return Optional.none(); } public String getName() { return name; } public void addParamValues(String name, String[] value) { if (!params.containsKey(name)) { params.put(name, value); } } public void addStrictFP(boolean sfp) { strictFP |= sfp; } public boolean isStrictFP() { return strictFP; } public void addModes(Mode eMode) { modes.add(eMode); } public void addModes(Mode[] eModes) { Collections.addAll(modes, eModes); } public Set getModes() { return modes; } public int[] getGroupThreads() { int[] threads = new int[methods.size()]; int c = 0; for (MethodInvocation mi : methods) { threads[c++] = mi.threads; } return threads; } public Optional> getGroupLabels() { if (methods.size() > 1) { Collection labels = new ArrayList<>(); for (MethodInvocation mi : methods) { labels.add(mi.method.getName()); } return Optional.eitherOf(labels); } else { return Optional.none(); } } public Optional getOperationsPerInvocation() { for (OperationsPerInvocation ann : getAll(OperationsPerInvocation.class)) { return Optional.of(ann.value()); } return Optional.none(); } public Optional getOutputTimeUnit() { for (OutputTimeUnit ann : getAll(OutputTimeUnit.class)) { return Optional.of(ann.value()); } return Optional.none(); } public Optional getWarmupIterations() { for (Warmup ann : getAll(Warmup.class)) { if (ann.iterations() != Warmup.BLANK_ITERATIONS) { return Optional.of(ann.iterations()); } } return Optional.none(); } public Optional getWarmupTime() { for (Warmup ann : getAll(Warmup.class)) { if (ann.time() != Warmup.BLANK_TIME) { return Optional.of(new TimeValue(ann.time(), ann.timeUnit())); } } return Optional.none(); } public Optional getWarmupBatchSize() { for (Warmup ann : getAll(Warmup.class)) { if (ann.batchSize() != Warmup.BLANK_BATCHSIZE) { return Optional.of(ann.batchSize()); } } return Optional.none(); } public Optional getMeasurementIterations() { for (Measurement ann : getAll(Measurement.class)) { if (ann.iterations() != Measurement.BLANK_ITERATIONS) { return Optional.of(ann.iterations()); } } return Optional.none(); } public Optional getMeasurementTime() { for (Measurement ann : getAll(Measurement.class)) { if (ann.time() != Measurement.BLANK_TIME) { return Optional.of(new TimeValue(ann.time(), ann.timeUnit())); } } return Optional.none(); } public Optional getMeasurementBatchSize() { for (Measurement ann : getAll(Measurement.class)) { if (ann.batchSize() != Measurement.BLANK_BATCHSIZE) { return Optional.of(ann.batchSize()); } } return Optional.none(); } public Optional getForks() { for (Fork ann : getAll(Fork.class)) { if (ann.value() != Fork.BLANK_FORKS) { return Optional.of(ann.value()); } } return Optional.none(); } public Optional getWarmupForks() { for (Fork ann : getAll(Fork.class)) { if (ann.warmups() != Fork.BLANK_FORKS) { return Optional.of(ann.warmups()); } } return Optional.none(); } public Optional getJvm() { for (Fork ann : getAll(Fork.class)) { if (!ann.jvm().equals(Fork.BLANK_ARGS)) { return Optional.of(ann.jvm()); } } return Optional.none(); } public Optional> getJvmArgs() { for (Fork ann : getAll(Fork.class)) { String[] args = ann.jvmArgs(); if (!(args.length == 1 && args[0].equals(Fork.BLANK_ARGS))) { return Optional.>of(Arrays.asList(args)); } } return Optional.none(); } public Optional> getJvmArgsAppend() { for (Fork ann : getAll(Fork.class)) { String[] args = ann.jvmArgsAppend(); if (!(args.length == 1 && args[0].equals(Fork.BLANK_ARGS))) { return Optional.>of(Arrays.asList(args)); } } return Optional.none(); } public Optional> getJvmArgsPrepend() { for (Fork ann : getAll(Fork.class)) { String[] args = ann.jvmArgsPrepend(); if (!(args.length == 1 && args[0].equals(Fork.BLANK_ARGS))) { return Optional.>of(Arrays.asList(args)); } } return Optional.none(); } public Optional getTimeout() { for (Timeout ann : getAll(Timeout.class)) { return Optional.of(new TimeValue(ann.time(), ann.timeUnit())); } return Optional.none(); } private Collection getAll(Class annClass) { Collection results = new ArrayList<>(); for (MethodInvocation mi : methods) { Collection anns = BenchmarkGeneratorUtils.getAnnSuperAll(mi.method, ci, annClass); if (!(results.isEmpty() || anns.isEmpty() || results.equals(anns))) { throw new GenerationException("Colliding annotations: " + anns + " vs. " + results, mi.method); } results = anns; } return results; } public Optional> getParams() { Map map = new TreeMap<>(); for (Map.Entry e : params.entrySet()) { String key = e.getKey(); String[] values = e.getValue(); if (values.length == 1 && values[0].equalsIgnoreCase(Param.BLANK_ARGS)) { map.put(key, new String[0]); } else { map.put(key, values); } } if (params.isEmpty()) { return Optional.none(); } else { return Optional.of(map); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodInfo.java000066400000000000000000000050221446271450100273640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import java.lang.annotation.Annotation; import java.util.Collection; /** * Method info. */ public interface MethodInfo extends Comparable, MetadataInfo { /** * @return short method name. */ String getName(); /** * @return fully qualified method name, includes class qualified name */ String getQualifiedName(); /** * @return fully qualified return type */ String getReturnType(); /** * @return collection of method parameters. */ Collection getParameters(); /** * @return reference to syntactically-enclosing class */ ClassInfo getDeclaringClass(); /** * @param annClass annotation class * @param annotation type * @return method-level annotation, if any; null otherwise */ T getAnnotation(Class annClass); /** * @return true, if method is public */ boolean isPublic(); /** * @return true, if method is abstract */ boolean isAbstract(); /** * @return true, if method is synchronized */ boolean isSynchronized(); /** * @return true, if method is strictfp */ boolean isStrictFP(); /** * @return true, if method is static */ boolean isStatic(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodInvocation.java000066400000000000000000000040121446271450100306000ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; class MethodInvocation implements Comparable { public final MethodInfo method; public final int threads; public MethodInvocation(MethodInfo method, int threads) { this.method = method; this.threads = threads; } @Override public int compareTo(MethodInvocation o) { return method.getName().compareTo(o.method.getName()); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MethodInvocation that = (MethodInvocation) o; if (!method.getName().equals(that.method.getName())) return false; return true; } @Override public int hashCode() { return method.getName().hashCode(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Paddings.java000066400000000000000000000044331446271450100270660ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import java.io.PrintWriter; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.StringJoiner; public class Paddings { private static final Map PADDING_CACHE = Collections.synchronizedMap(new HashMap<>()); private static String generate(String prefix) { if (prefix.isEmpty()) { throw new IllegalArgumentException("prefix must not be empty"); } StringJoiner sj = new StringJoiner(""); for (int p = 0; p < 16; p++) { sj.add(" byte "); for (int q = 0; q < 16; q++) { if (q != 0) { sj.add(", "); } sj.add(prefix); sj.add(String.format("%03d", p * 16 + q)); } sj.add(";"); sj.add(System.lineSeparator()); } return sj.toString(); } public static void padding(PrintWriter writer, String prefix) { writer.print(PADDING_CACHE.computeIfAbsent(prefix, Paddings::generate)); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/ParameterInfo.java000066400000000000000000000026151446271450100300710ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; /** * Method parameter metadata. */ public interface ParameterInfo extends MetadataInfo { /** * @return parameter type */ ClassInfo getType(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/SourceElementError.java000066400000000000000000000031101446271450100311100ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; public class SourceElementError extends SourceError { private final MetadataInfo element; public SourceElementError(String message, MetadataInfo element) { super(message); this.element = element; } @Override public String toString() { return super.toString() + "\n [" + element.toString() + "]"; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/SourceElementWarning.java000066400000000000000000000031161446271450100314320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; public class SourceElementWarning extends SourceWarning { private final MetadataInfo element; public SourceElementWarning(String message, MetadataInfo element) { super(message); this.element = element; } @Override public String toString() { return super.toString() + "\n [" + element.toString() + "]"; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/SourceError.java000066400000000000000000000030031446271450100275770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; public class SourceError { private final String message; public SourceError(String message) { this.message = message; } public String getMessage() { return message; } @Override public String toString() { return message; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/SourceThrowableError.java000066400000000000000000000031561446271450100314600ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.util.Utils; public class SourceThrowableError extends SourceError { private final Throwable element; public SourceThrowableError(String message, Throwable element) { super(message); this.element = element; } @Override public String toString() { return super.toString() + "\n" + Utils.throwableToString(element); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/SourceThrowableWarning.java000066400000000000000000000031641446271450100317730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.util.Utils; public class SourceThrowableWarning extends SourceWarning { private final Throwable element; public SourceThrowableWarning(String message, Throwable element) { super(message); this.element = element; } @Override public String toString() { return super.toString() + "\n" + Utils.throwableToString(element); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/SourceWarning.java000066400000000000000000000030071446271450100301170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; public class SourceWarning { private final String message; public SourceWarning(String message) { this.message = message; } public String getMessage() { return message; } @Override public String toString() { return message; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java000066400000000000000000000131631446271450100275440ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.TreeMultimap; import java.util.*; class StateObject { public static final Comparator ID_COMPARATOR = Comparator.comparing(o -> o.fieldIdentifier); public final String packageName; public final String userType; public final String type; public final Scope scope; public final String localIdentifier; public final String fieldIdentifier; public final Multimap params; public final SortedSet helpers; public final Multimap helperArgs; public final List depends; public StateObject(Identifiers identifiers, ClassInfo info, Scope scope) { this.packageName = info.getPackageName() + "." + BenchmarkGenerator.JMH_GENERATED_SUBPACKAGE; this.userType = info.getQualifiedName(); this.type = identifiers.getJMHtype(info); this.scope = scope; String id = identifiers.collapseTypeName(userType) + identifiers.identifier(scope); this.localIdentifier = "l_" + id; this.fieldIdentifier = "f_" + id; this.params = new TreeMultimap<>(); this.helpers = new TreeSet<>(); this.helperArgs = new HashMultimap<>(); this.depends = new ArrayList<>(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StateObject that = (StateObject) o; if (!fieldIdentifier.equals(that.fieldIdentifier)) return false; if (scope != that.scope) return false; if (!Objects.equals(type, that.type)) return false; return true; } @Override public int hashCode() { int result = type != null ? type.hashCode() : 0; result = 31 * result + (scope != null ? scope.hashCode() : 0); result = 31 * result + (fieldIdentifier.hashCode()); return result; } public String toTypeDef() { return type + " " + localIdentifier; } public String toLocal() { return localIdentifier; } public Collection getParamsLabels() { return params.keys(); } public void addParam(FieldInfo fieldInfo) { params.put(fieldInfo.getName(), fieldInfo); } public Collection getParam(String name) { return params.get(name); } public String getParamAccessor(FieldInfo paramField) { String name = paramField.getName(); String type = paramField.getType().getQualifiedName(); if (type.equalsIgnoreCase("java.lang.String")) { return "control.getParam(\"" + name + "\")"; } if (type.equalsIgnoreCase("boolean") || type.equalsIgnoreCase("java.lang.Boolean")) { return "Boolean.valueOf(control.getParam(\"" + name + "\"))"; } if (type.equalsIgnoreCase("byte") || type.equalsIgnoreCase("java.lang.Byte")) { return "Byte.valueOf(control.getParam(\"" + name + "\"))"; } if (type.equalsIgnoreCase("char") || type.equalsIgnoreCase("java.lang.Character")) { return "(control.getParam(\"" + name + "\")).charAt(0)"; } if (type.equalsIgnoreCase("short") || type.equalsIgnoreCase("java.lang.Short")) { return "Short.valueOf(control.getParam(\"" + name + "\"))"; } if (type.equalsIgnoreCase("int") || type.equalsIgnoreCase("java.lang.Integer")) { return "Integer.valueOf(control.getParam(\"" + name + "\"))"; } if (type.equalsIgnoreCase("float") || type.equalsIgnoreCase("java.lang.Float")) { return "Float.valueOf(control.getParam(\"" + name + "\"))"; } if (type.equalsIgnoreCase("long") || type.equalsIgnoreCase("java.lang.Long")) { return "Long.valueOf(control.getParam(\"" + name + "\"))"; } if (type.equalsIgnoreCase("double") || type.equalsIgnoreCase("java.lang.Double")) { return "Double.valueOf(control.getParam(\"" + name + "\"))"; } // assume enum return type + ".valueOf(control.getParam(\"" + name + "\"))"; } public void addHelper(HelperMethodInvocation hmi) { helpers.add(hmi); } public Collection getHelpers() { return helpers; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java000066400000000000000000001367261446271450100310550ustar00rootroot00000000000000/* * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.*; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.Utils; import java.io.IOException; import java.io.PrintWriter; import java.lang.annotation.Annotation; import java.lang.annotation.IncompleteAnnotationException; import java.util.*; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; class StateObjectHandler { private final CompilerControlPlugin compileControl; private final Identifiers identifiers; private final Multimap roots; private final Multimap specials; private final Set stateObjects; private final Map implicits; private final Multimap benchmarkArgs; private final Multimap auxNames = new HashMultimap<>(); private final Map auxType = new HashMap<>(); private final Map auxAccessors = new HashMap<>(); private final Map auxResettable = new HashMap<>(); public StateObjectHandler(CompilerControlPlugin compileControl) { this.compileControl = compileControl; this.roots = new HashMultimap<>(); this.benchmarkArgs = new HashMultimap<>(); this.implicits = new HashMap<>(); this.specials = new HashMultimap<>(); this.stateObjects = new HashSet<>(); this.identifiers = new Identifiers(); } public static void validateState(ClassInfo state) { // Because of https://bugs.openjdk.java.net/browse/JDK-8031122, // we need to preemptively check the annotation value, and // the API can only allow that by catching the exception, argh. try { State ann = BenchmarkGeneratorUtils.getAnnSuper(state, State.class); if (ann != null) { ann.value(); } } catch (IncompleteAnnotationException iae) { throw new GenerationException("The @" + State.class.getSimpleName() + " annotation should have the explicit " + Scope.class.getSimpleName() + " argument", state); } if (!state.isPublic()) { throw new GenerationException("The instantiated @" + State.class.getSimpleName() + " annotation only supports public classes.", state); } if (state.isFinal()) { throw new GenerationException("The instantiated @" + State.class.getSimpleName() + " annotation does not support final classes." , state); } if (state.isInner()) { throw new GenerationException("The instantiated @" + State.class.getSimpleName() + " annotation does not support inner classes, make sure your class is static.", state); } if (state.isAbstract()) { throw new GenerationException("The instantiated @" + State.class.getSimpleName() + " class cannot be abstract.", state); } boolean hasDefaultConstructor = false; for (MethodInfo constructor : state.getConstructors()) { if (constructor.getParameters().isEmpty()) { hasDefaultConstructor = constructor.isPublic(); break; } } // These classes use the special init sequence: hasDefaultConstructor |= state.getQualifiedName().equals(BenchmarkParams.class.getCanonicalName()); hasDefaultConstructor |= state.getQualifiedName().equals(IterationParams.class.getCanonicalName()); hasDefaultConstructor |= state.getQualifiedName().equals(ThreadParams.class.getCanonicalName()); if (!hasDefaultConstructor) { throw new GenerationException("The @" + State.class.getSimpleName() + " annotation can only be applied to the classes having the default public constructor.", state); } // validate rogue annotations on classes BenchmarkGeneratorUtils.checkAnnotations(state); for (FieldInfo fi : BenchmarkGeneratorUtils.getAllFields(state)) { BenchmarkGeneratorUtils.checkAnnotations(fi); } // validate rogue annotations on methods for (MethodInfo mi : BenchmarkGeneratorUtils.getAllMethods(state)) { BenchmarkGeneratorUtils.checkAnnotations(mi); } // check @Setup/@TearDown have only @State arguments for (MethodInfo mi : BenchmarkGeneratorUtils.getAllMethods(state)) { if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) { validateStateArgs(mi); } } } public static void validateStateArgs(MethodInfo e) { for (ParameterInfo var : e.getParameters()) { if (BenchmarkGeneratorUtils.getAnnSuper(var.getType(), State.class) != null) continue; if (isSpecialClass(var.getType())) continue; throw new GenerationException( "Method parameters should be either @" + State.class.getSimpleName() + " classes or one of special JMH classes (*Params, Blackhole, Control)", e); } } private static boolean isSpecialClass(ClassInfo ci) { String name = ci.getQualifiedName(); return name.equals(BenchmarkParams.class.getCanonicalName()) || name.equals(IterationParams.class.getCanonicalName()) || name.equals(ThreadParams.class.getCanonicalName()) || name.equals(Blackhole.class.getCanonicalName()) || name.equals(Control.class.getCanonicalName()) ; } private String getSpecialClassAccessor(ClassInfo pci) { String name = pci.getQualifiedName(); if (name.equals(BenchmarkParams.class.getCanonicalName())) return "benchmarkParams"; if (name.equals(IterationParams.class.getCanonicalName())) return "iterationParams"; if (name.equals(ThreadParams.class.getCanonicalName())) return "threadParams"; if (name.equals(Blackhole.class.getCanonicalName())) return "blackhole"; if (name.equals(Control.class.getCanonicalName())) return "notifyControl"; throw new GenerationException("Internal error, unhandled special class: " + pci, pci); } public State getState(ClassInfo ci, ParameterInfo pi) { State ann = BenchmarkGeneratorUtils.getAnnSuper(ci, State.class); if (ann == null) { throw new GenerationException("The method parameter is not a @" + State.class.getSimpleName() + ": ", pi); } return ann; } public void bindMethods(ClassInfo holder, MethodGroup mg) { for (MethodInfo method : mg.methods()) { // Bind the holder implicitly: { State ann = BenchmarkGeneratorUtils.getAnnSuper(holder, State.class); Scope scope = (ann != null) ? ann.value() : Scope.Thread; StateObject holderSo = new StateObject(identifiers, holder, scope); stateObjects.add(holderSo); implicits.put("bench", holderSo); bindState(method, holderSo, holder); resolveDependencies(method, holder, holderSo); } // Check that all arguments are states. validateStateArgs(method); // Bind all @Benchmark parameters for (ParameterInfo ppi : method.getParameters()) { ClassInfo pci = ppi.getType(); if (isSpecialClass(pci)) { benchmarkArgs.put(method.getName(), getSpecialClassAccessor(pci)); specials.put(method.getName(), pci); } else { StateObject pso = new StateObject(identifiers, pci, getState(pci, ppi).value()); stateObjects.add(pso); roots.put(method.getName(), pso); benchmarkArgs.put(method.getName(), pso.toLocal()); bindState(method, pso, pci); resolveDependencies(method, pci, pso); } } } } public static void validateNoCycles(MethodInfo method) { validateNoCyclesStep(Collections.emptySet(), method, true); } private static void validateNoCyclesStep(Set alreadySeen, MethodInfo method, boolean includeHolder) { // Collect and check outgoing edges Set outgoing = new HashSet<>(); if (includeHolder) { outgoing.add(new ClassQName(method.getDeclaringClass())); } for (ParameterInfo ppi : method.getParameters()) { outgoing.add(new ClassQName(ppi.getType())); } if (outgoing.isEmpty()) { // No outgoing edges, checks complete. return; } Set currentSeen = new HashSet<>(); currentSeen.addAll(alreadySeen); for (ClassQName ci : outgoing) { // Try see if we have already seen these edges for current method. // If so, this is a dependency cycle. if (!currentSeen.add(ci)) { throw new GenerationException("@" + State.class.getSimpleName() + " dependency cycle is detected: " + ci.ci.getQualifiedName() + " " + currentSeen, method); } // For each fixture method that needs the state, see if we need to initialize those as well. // Restart the search from already seen + the outgoing edge. Set nextSeen = new HashSet<>(); nextSeen.addAll(alreadySeen); nextSeen.add(ci); for (MethodInfo mi : BenchmarkGeneratorUtils.getAllMethods(ci.ci)) { if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) { validateNoCyclesStep(nextSeen, mi, false); } } } } private static class ClassQName { private final ClassInfo ci; private ClassQName(ClassInfo ci) { this.ci = ci; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ClassQName cycleInfo = (ClassQName) o; return Objects.equals(ci.getQualifiedName(), cycleInfo.ci.getQualifiedName()); } @Override public int hashCode() { return Objects.hash(ci.getQualifiedName()); } } /** * Recursively resolve if there are any other states referenced through helper methods. */ private void resolveDependencies(MethodInfo method, ClassInfo pci, StateObject pso) { for (MethodInfo mi : BenchmarkGeneratorUtils.getAllMethods(pci)) { if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) { for (ParameterInfo pi : mi.getParameters()) { ClassInfo ci = pi.getType(); if (isSpecialClass(ci)) { pso.helperArgs.put(mi.getQualifiedName(), getSpecialClassAccessor(ci)); specials.put(mi.getQualifiedName(), ci); } else { StateObject so = new StateObject(identifiers, ci, getState(ci, pi).value()); stateObjects.add(so); pso.helperArgs.put(mi.getQualifiedName(), so.toLocal()); if (!pso.depends.contains(so)) { pso.depends.add(so); bindState(method, so, ci); resolveDependencies(method, ci, so); } } } } } } private void bindState(MethodInfo execMethod, StateObject so, ClassInfo ci) { // Check it is a valid state validateState(ci); // auxiliary result, produce the accessors AuxCounters auxCountAnn = ci.getAnnotation(AuxCounters.class); if (auxCountAnn != null) { if (so.scope != Scope.Thread) { throw new GenerationException("@" + AuxCounters.class.getSimpleName() + " can only be used with " + Scope.class.getSimpleName() + "." + Scope.Thread + " states.", ci); } for (FieldInfo sub : ci.getFields()) { if (sub.isPublic()) { if (!isAuxCompatible(sub.getType().getQualifiedName())) { throw new GenerationException("Illegal type for the public field in @" + AuxCounters.class.getSimpleName() + ".", sub); } String name = sub.getName(); String meth = execMethod.getName(); auxNames.put(meth, name); auxType.put(name, auxCountAnn.value()); auxResettable.put(name, true); String prev = auxAccessors.put(meth + name, so.localIdentifier + "." + name); if (prev != null) { throw new GenerationException("Conflicting @" + AuxCounters.class.getSimpleName() + " counters. Make sure there are no @" + State.class.getSimpleName() + "-s with the same counter " + " injected into this method.", sub); } } } for (MethodInfo sub : ci.getMethods()) { if (sub.isPublic() && !sub.getReturnType().equals("void")) { if (!isAuxCompatible(sub.getReturnType())) { throw new GenerationException("Illegal type for the return type of public method in @" + AuxCounters.class.getSimpleName() + ".", sub); } String name = sub.getName(); String meth = execMethod.getName(); auxNames.put(meth, name); auxType.put(name, auxCountAnn.value()); auxResettable.put(name, false); String prev = auxAccessors.put(meth + name, so.localIdentifier + "." + name + "()"); if (prev != null) { throw new GenerationException("Conflicting @" + AuxCounters.class.getSimpleName() + " counters. Make sure there are no @" + State.class.getSimpleName() + "-s with the same counter " + " injected into this method.", sub); } } } } // walk the type hierarchy up to discover inherited @Params for (FieldInfo fi : BenchmarkGeneratorUtils.getAllFields(ci)) { if (fi.getAnnotation(Param.class) != null) { checkParam(fi); so.addParam(fi); } } // put the @State objects helper methods for (MethodInfo mi : BenchmarkGeneratorUtils.getAllMethods(ci)) { Setup setupAnn = mi.getAnnotation(Setup.class); if (setupAnn != null) { checkHelpers(mi, Setup.class); so.addHelper(new HelperMethodInvocation(mi, so, setupAnn.value(), HelperType.SETUP)); compileControl.defaultForceInline(mi); } TearDown tearDownAnn = mi.getAnnotation(TearDown.class); if (tearDownAnn != null) { checkHelpers(mi, TearDown.class); so.addHelper(new HelperMethodInvocation(mi, so, tearDownAnn.value(), HelperType.TEARDOWN)); compileControl.defaultForceInline(mi); } } } private boolean isAuxCompatible(String typeName) { if (typeName.equals("byte") || typeName.equals("java.lang.Byte")) return true; if (typeName.equals("short") || typeName.equals("java.lang.Short")) return true; if (typeName.equals("int") || typeName.equals("java.lang.Integer")) return true; if (typeName.equals("float") || typeName.equals("java.lang.Float")) return true; if (typeName.equals("long") || typeName.equals("java.lang.Long")) return true; if (typeName.equals("double") || typeName.equals("java.lang.Double")) return true; return false; } private void checkParam(FieldInfo fi) { if (fi.isFinal()) { throw new GenerationException( "@" + Param.class.getSimpleName() + " annotation is not acceptable on final fields.", fi); } if (BenchmarkGeneratorUtils.getAnnSyntax(fi.getDeclaringClass(), State.class) == null) { throw new GenerationException( "@" + Param.class.getSimpleName() + " annotation should be placed in @" + State.class.getSimpleName() + "-annotated class.", fi); } ClassInfo type = fi.getType(); if (!isParamTypeAcceptable(type)) { throw new GenerationException( "@" + Param.class.getSimpleName() + " can only be placed over the annotation-compatible types:" + " primitives, primitive wrappers, Strings, or enums.", fi); } String[] values = fi.getAnnotation(Param.class).value(); if (values.length == 1 && values[0].equalsIgnoreCase(Param.BLANK_ARGS)) { if (!fi.getType().isEnum()) { throw new GenerationException( "@" + Param.class.getSimpleName() + " should provide the default parameters.", fi); } else { // if type is enum then don't need to check conformity } } else { for (String val : values) { if (!isParamValueConforming(fi, val, type)) { throw new GenerationException( "Some @" + Param.class.getSimpleName() + " values can not be converted to target type: " + "\"" + val + "\" can not be converted to " + type, fi ); } } } } private boolean isParamTypeAcceptable(ClassInfo type) { String typeName = type.getQualifiedName(); if (type.isEnum()) return true; if (typeName.equals("java.lang.String")) return true; if (typeName.equals("boolean") || typeName.equals("java.lang.Boolean")) return true; if (typeName.equals("byte") || typeName.equals("java.lang.Byte")) return true; if (typeName.equals("char") || typeName.equals("java.lang.Character")) return true; if (typeName.equals("short") || typeName.equals("java.lang.Short")) return true; if (typeName.equals("int") || typeName.equals("java.lang.Integer")) return true; if (typeName.equals("float") || typeName.equals("java.lang.Float")) return true; if (typeName.equals("long") || typeName.equals("java.lang.Long")) return true; if (typeName.equals("double") || typeName.equals("java.lang.Double")) return true; return false; } private boolean isParamValueConforming(FieldInfo fi, String val, ClassInfo type) { String typeName = type.getQualifiedName(); if (type.isEnum()) { if (type.getEnumConstants().contains(val)) { return true; } } if (typeName.equals("java.lang.String")) { return true; } if (typeName.equals("boolean") || typeName.equals("java.lang.Boolean")) { return (val.equals("true") || val.equals("false")); } if (typeName.equals("byte") || typeName.equals("java.lang.Byte")) { try { Byte.parseByte(val); return true; } catch (NumberFormatException nfe) { return false; } } if (typeName.equals("char") || typeName.equals("java.lang.Character")) { return (val.length() == 1); } if (typeName.equals("short") || typeName.equals("java.lang.Short")) { try { Short.parseShort(val); return true; } catch (NumberFormatException nfe) { return false; } } if (typeName.equals("int") || typeName.equals("java.lang.Integer")) { try { Integer.parseInt(val); return true; } catch (NumberFormatException nfe) { return false; } } if (typeName.equals("float") || typeName.equals("java.lang.Float")) { try { Float.parseFloat(val); return true; } catch (NumberFormatException nfe) { return false; } } if (typeName.equals("long") || typeName.equals("java.lang.Long")) { try { Long.parseLong(val); return true; } catch (NumberFormatException nfe) { return false; } } if (typeName.equals("double") || typeName.equals("java.lang.Double")) { try { Double.parseDouble(val); return true; } catch (NumberFormatException nfe) { return false; } } return false; } private void checkHelpers(MethodInfo mi, Class annClass) { // OK to have these annotation for @State objects if (BenchmarkGeneratorUtils.getAnnSuper(mi.getDeclaringClass(), State.class) == null) { if (!mi.getDeclaringClass().isAbstract()) { throw new GenerationException( "@" + annClass.getSimpleName() + " annotation is placed within " + "a class not having @" + State.class.getSimpleName() + " annotation. " + "This is prohibited because it would have no effect.", mi); } } if (!mi.isPublic()) { throw new GenerationException( "@" + annClass.getSimpleName() + " method should be public.", mi); } if (!mi.getReturnType().equalsIgnoreCase("void")) { throw new GenerationException( "@" + annClass.getSimpleName() + " method should not return anything.", mi); } } public String getBenchmarkArgList(MethodInfo methodInfo) { return Utils.join(benchmarkArgs.get(methodInfo.getName()), ", "); } public String getArgList(MethodInfo methodInfo) { return getArgList(stateOrder(methodInfo, false)); } public String getArgList(Collection sos) { StringBuilder sb = new StringBuilder(); int i = 0; for (StateObject so : sos) { if (i != 0) { sb.append(", "); } sb.append(so.toLocal()); i++; } return sb.toString(); } public String getTypeArgList(MethodInfo methodInfo) { return getTypeArgList(stateOrder(methodInfo, false)); } public String getTypeArgList(Collection sos) { StringBuilder sb = new StringBuilder(); int i = 0; for (StateObject so : sos) { if (i != 0) { sb.append(", "); } sb.append(so.toTypeDef()); i++; } return sb.toString(); } @SafeVarargs public static Collection cons(Collection... colls) { SortedSet r = new TreeSet<>(StateObject.ID_COMPARATOR); for (Collection coll : colls) { r.addAll(coll); } return r; } public Collection getHelperBlock(MethodInfo method, Level helperLevel, HelperType type) { // Look for the offending methods. // This will be used to skip the irrelevant blocks for state objects down the stream. List statesForward = new ArrayList<>(); for (StateObject so : stateOrder(method, true)) { for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel == helperLevel) { statesForward.add(so); break; } } } List statesReverse = new ArrayList<>(); for (StateObject so : stateOrder(method, false)) { for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel == helperLevel) { statesReverse.add(so); break; } } } List result = new ArrayList<>(); // Handle Thread object helpers for (StateObject so : statesForward) { if (type != HelperType.SETUP) continue; if (so.scope == Scope.Thread) { for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.SETUP) { Collection args = so.helperArgs.get(mi.method.getQualifiedName()); result.add(so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } } if (so.scope == Scope.Benchmark || so.scope == Scope.Group) { result.add("if (" + so.type + ".setup" + helperLevel + "MutexUpdater.compareAndSet(" + so.localIdentifier + ", 0, 1)) {"); result.add(" try {"); result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" if (!" + so.localIdentifier + ".ready" + helperLevel + ") {"); for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.SETUP) { Collection args = so.helperArgs.get(mi.method.getQualifiedName()); result.add(" " + so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } result.add(" " + so.localIdentifier + ".ready" + helperLevel + " = true;"); result.add(" }"); result.add(" } catch (Throwable t) {"); result.add(" control.isFailing = true;"); result.add(" throw t;"); result.add(" } finally {"); result.add(" " + so.type + ".setup" + helperLevel + "MutexUpdater.set(" + so.localIdentifier + ", 0);"); result.add(" }"); result.add("} else {"); result.add(" while (" + so.type + ".setup" + helperLevel + "MutexUpdater.get(" + so.localIdentifier + ") == 1) {"); result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" if (Thread.interrupted()) throw new InterruptedException();"); result.add(" }"); result.add("}"); } } for (StateObject so : statesReverse) { if (type != HelperType.TEARDOWN) continue; if (so.scope == Scope.Thread) { for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) { Collection args = so.helperArgs.get(mi.method.getQualifiedName()); result.add(so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } } if (so.scope == Scope.Benchmark || so.scope == Scope.Group) { result.add("if (" + so.type + ".tear" + helperLevel + "MutexUpdater.compareAndSet(" + so.localIdentifier + ", 0, 1)) {"); result.add(" try {"); result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" if (" + so.localIdentifier + ".ready" + helperLevel + ") {"); for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) { Collection args = so.helperArgs.get(mi.method.getQualifiedName()); result.add(" " + so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } result.add(" " + so.localIdentifier + ".ready" + helperLevel + " = false;"); result.add(" }"); result.add(" } catch (Throwable t) {"); result.add(" control.isFailing = true;"); result.add(" throw t;"); result.add(" } finally {"); result.add(" " + so.type + ".tear" + helperLevel + "MutexUpdater.set(" + so.localIdentifier + ", 0);"); result.add(" }"); result.add("} else {"); // We don't need to actively busy-wait for Trial, it is way past the measurement window, // and we would not need measurement threads anymore after this is over. Therefore, it // is OK to exponentially back off. if (helperLevel == Level.Trial) { result.add(" long " + so.localIdentifier + "_backoff = 1;"); } result.add(" while (" + so.type + ".tear" + helperLevel + "MutexUpdater.get(" + so.localIdentifier + ") == 1) {"); if (helperLevel == Level.Trial) { result.add(" TimeUnit.MILLISECONDS.sleep(" + so.localIdentifier + "_backoff);"); result.add(" " + so.localIdentifier + "_backoff = Math.max(1024, " + so.localIdentifier + "_backoff * 2);"); } result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" if (Thread.interrupted()) throw new InterruptedException();"); result.add(" }"); result.add("}"); } } return result; } public boolean hasInvocationStubs(MethodInfo method) { return !getInvocationSetups(method).isEmpty() || !getInvocationTearDowns(method).isEmpty(); } public Collection getInvocationSetups(MethodInfo method) { return getHelperBlock(method, Level.Invocation, HelperType.SETUP); } public Collection getInvocationTearDowns(MethodInfo method) { return getHelperBlock(method, Level.Invocation, HelperType.TEARDOWN); } public Collection getIterationSetups(MethodInfo method) { return getHelperBlock(method, Level.Iteration, HelperType.SETUP); } public Collection getIterationTearDowns(MethodInfo method) { return getHelperBlock(method, Level.Iteration, HelperType.TEARDOWN); } public Collection getRunSetups(MethodInfo method) { return getHelperBlock(method, Level.Trial, HelperType.SETUP); } public Collection getRunTearDowns(MethodInfo method) { return getHelperBlock(method, Level.Trial, HelperType.TEARDOWN); } public List getStateInitializers() { Collection sos = cons(stateObjects); List result = new ArrayList<>(); for (StateObject so : sos) { if (so.scope != Scope.Benchmark) continue; result.add(""); result.add("static volatile " + so.type + " " + so.fieldIdentifier + ";"); result.add(""); result.add(so.type + " _jmh_tryInit_" + so.fieldIdentifier + "(InfraControl control" + soDependency_TypeArgs(so) + ") throws Throwable {"); result.add(" " + so.type + " val = " + so.fieldIdentifier + ";"); result.add(" if (val != null) {"); result.add(" return val;"); result.add(" }"); result.add(" synchronized(this.getClass()) {"); result.add(" try {"); result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" val = " + so.fieldIdentifier + ";"); result.add(" if (val != null) {"); result.add(" return val;"); result.add(" }"); result.add(" val = new " + so.type + "();"); if (!so.getParamsLabels().isEmpty()) { result.add(" Field f;"); } for (String paramName : so.getParamsLabels()) { for (FieldInfo paramField : so.getParam(paramName)) { result.add(" f = " + paramField.getDeclaringClass().getQualifiedName() + ".class.getDeclaredField(\"" + paramName + "\");"); result.add(" f.setAccessible(true);"); result.add(" f.set(val, " + so.getParamAccessor(paramField) + ");"); } } for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel != Level.Trial) continue; if (hmi.type != HelperType.SETUP) continue; Collection args = so.helperArgs.get(hmi.method.getQualifiedName()); result.add(" val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");"); } result.add(" val.ready" + Level.Trial + " = true;"); result.add(" " + so.fieldIdentifier + " = val;"); result.add(" } catch (Throwable t) {"); result.add(" control.isFailing = true;"); result.add(" throw t;"); result.add(" }"); result.add(" }"); result.add(" return val;"); result.add("}"); } for (StateObject so : sos) { if (so.scope != Scope.Thread) continue; result.add(""); result.add(so.type + " " + so.fieldIdentifier + ";"); result.add(""); result.add(so.type + " _jmh_tryInit_" + so.fieldIdentifier + "(InfraControl control" + soDependency_TypeArgs(so) + ") throws Throwable {"); result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" " + so.type + " val = " + so.fieldIdentifier + ";"); result.add(" if (val == null) {"); result.add(" val = new " + so.type + "();"); if (!so.getParamsLabels().isEmpty()) { result.add(" Field f;"); } for (String paramName : so.getParamsLabels()) { for (FieldInfo paramField : so.getParam(paramName)) { result.add(" f = " + paramField.getDeclaringClass().getQualifiedName() + ".class.getDeclaredField(\"" + paramName + "\");"); result.add(" f.setAccessible(true);"); result.add(" f.set(val, " + so.getParamAccessor(paramField) + ");"); } } for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel != Level.Trial) continue; if (hmi.type != HelperType.SETUP) continue; Collection args = so.helperArgs.get(hmi.method.getQualifiedName()); result.add(" val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");"); } result.add(" " + so.fieldIdentifier + " = val;"); result.add(" }"); result.add(" return val;"); result.add("}"); } for (StateObject so : sos) { if (so.scope != Scope.Group) continue; result.add(""); result.add("static java.util.Map " + so.fieldIdentifier + "_map = java.util.Collections.synchronizedMap(new java.util.HashMap());"); result.add(""); result.add(so.type + " _jmh_tryInit_" + so.fieldIdentifier + "(InfraControl control" + soDependency_TypeArgs(so) + ") throws Throwable {"); result.add(" int groupIdx = threadParams.getGroupIndex();"); result.add(" " + so.type + " val = " + so.fieldIdentifier + "_map.get(groupIdx);"); result.add(" if (val != null) {"); result.add(" return val;"); result.add(" }"); result.add(" synchronized(this.getClass()) {"); result.add(" try {"); result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" val = " + so.fieldIdentifier + "_map.get(groupIdx);"); result.add(" if (val != null) {"); result.add(" return val;"); result.add(" }"); result.add(" val = new " + so.type + "();"); if (!so.getParamsLabels().isEmpty()) { result.add(" Field f;"); } for (String paramName : so.getParamsLabels()) { for(FieldInfo paramField : so.getParam(paramName)) { result.add(" f = " + paramField.getDeclaringClass().getQualifiedName() + ".class.getDeclaredField(\"" + paramName + "\");"); result.add(" f.setAccessible(true);"); result.add(" f.set(val, " + so.getParamAccessor(paramField) + ");"); } } for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel != Level.Trial) continue; if (hmi.type != HelperType.SETUP) continue; Collection args = so.helperArgs.get(hmi.method.getQualifiedName()); result.add(" val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");"); } result.add(" " + "val.ready" + Level.Trial + " = true;"); result.add(" " + so.fieldIdentifier + "_map.put(groupIdx, val);"); result.add(" } catch (Throwable t) {"); result.add(" control.isFailing = true;"); result.add(" throw t;"); result.add(" }"); result.add(" }"); result.add(" return val;"); result.add("}"); } return result; } private String soDependency_TypeArgs(StateObject so) { return (so.depends.isEmpty() ? "" : ", " + getTypeArgList(so.depends)); } private String soDependency_Args(StateObject so) { return (so.depends.isEmpty() ? "" : ", " + getArgList(so.depends)); } public Collection getStateDestructors(MethodInfo method) { Collection sos = stateOrder(method, false); List result = new ArrayList<>(); for (StateObject so : sos) { if (so.scope != Scope.Benchmark) continue; result.add("synchronized(this.getClass()) {"); result.add(" " + so.fieldIdentifier + " = null;"); result.add("}"); } for (StateObject so : sos) { if (so.scope != Scope.Thread) continue; result.add("" + so.fieldIdentifier + " = null;"); } for (StateObject so : sos) { if (so.scope != Scope.Group) continue; result.add("synchronized(this.getClass()) {"); result.add(" " + so.fieldIdentifier + "_map.remove(threadParams.getGroupIndex());"); result.add("}"); } return result; } public List getStateGetters(MethodInfo method) { List result = new ArrayList<>(); for (StateObject so : stateOrder(method, true)) { result.add(so.type + " " + so.localIdentifier + " = _jmh_tryInit_" + so.fieldIdentifier + "(control" + soDependency_Args(so) + ");"); } return result; } private LinkedHashSet stateOrder(MethodInfo method, boolean reverse) { // Linearize @State dependency DAG List linearOrder = new ArrayList<>(); List stratum = new ArrayList<>(); // These are roots stratum.addAll(roots.get(method.getName())); stratum.addAll(implicits.values()); // Recursively walk the DAG while (!stratum.isEmpty()) { linearOrder.addAll(stratum); List newStratum = new ArrayList<>(); for (StateObject so : stratum) { newStratum.addAll(so.depends); } stratum = newStratum; } if (reverse) { Collections.reverse(linearOrder); } return new LinkedHashSet<>(linearOrder); } public void writeStateOverrides(BenchmarkGeneratorSession sess, GeneratorDestination dst) throws IOException { for (StateObject so : cons(stateObjects)) { if (!sess.generatedStateOverrides.add(so.userType)) continue; { PrintWriter pw = new PrintWriter(dst.newClass(so.packageName + "." + so.type + "_B1", so.userType)); pw.println("package " + so.packageName + ";"); pw.println("import " + so.userType + ";"); pw.println("public class " + so.type + "_B1 extends " + so.userType + " {"); Paddings.padding(pw, "b1_"); pw.println("}"); pw.close(); } { PrintWriter pw = new PrintWriter(dst.newClass(so.packageName + "." + so.type + "_B2", so.userType)); pw.println("package " + so.packageName + ";"); pw.println("import " + AtomicIntegerFieldUpdater.class.getCanonicalName() + ";"); pw.println("public class " + so.type + "_B2 extends " + so.type + "_B1 {"); for (Level level : Level.values()) { pw.println(" public volatile int setup" + level + "Mutex;"); pw.println(" public volatile int tear" + level + "Mutex;"); pw.println(" public final static AtomicIntegerFieldUpdater<" + so.type + "_B2> setup" + level + "MutexUpdater = " + "AtomicIntegerFieldUpdater.newUpdater(" + so.type + "_B2.class, \"setup" + level + "Mutex\");"); pw.println(" public final static AtomicIntegerFieldUpdater<" + so.type + "_B2> tear" + level + "MutexUpdater = " + "AtomicIntegerFieldUpdater.newUpdater(" + so.type + "_B2.class, \"tear" + level + "Mutex\");"); pw.println(""); } switch (so.scope) { case Benchmark: case Group: for (Level level : Level.values()) { pw.println(" public volatile boolean ready" + level + ";"); } break; case Thread: // these flags are redundant for single thread break; default: throw new IllegalStateException("Unknown state scope: " + so.scope); } pw.println("}"); pw.close(); } { PrintWriter pw = new PrintWriter(dst.newClass(so.packageName + "." + so.type + "_B3", so.userType)); pw.println("package " + so.packageName + ";"); pw.println("public class " + so.type + "_B3 extends " + so.type + "_B2 {"); Paddings.padding(pw, "b3_"); pw.println("}"); pw.println(""); pw.close(); } { PrintWriter pw = new PrintWriter(dst.newClass(so.packageName + "." + so.type, so.userType)); pw.println("package " + so.packageName + ";"); pw.println("public class " + so.type + " extends " + so.type + "_B3 {"); pw.println("}"); pw.println(""); pw.close(); } } } public Collection getFields() { return Collections.emptyList(); } public StateObject getImplicit(String label) { return implicits.get(label); } public void addImports(PrintWriter writer) { for (StateObject so : cons(stateObjects)) { writer.println("import " + so.packageName + "." + so.type + ";"); } } public Collection getAuxResets(MethodInfo method) { Collection result = new ArrayList<>(); for (String name : auxNames.get(method.getName())) { if (auxResettable.get(name)) { result.add(auxAccessors.get(method.getName() + name) + " = 0;"); } } return result; } public Collection getAuxResults(MethodInfo method, String opResName) { Collection result = new ArrayList<>(); for (String ops : auxNames.get(method.getName())) { AuxCounters.Type type = auxType.get(ops); switch (type) { case OPERATIONS: switch (opResName) { case "ThroughputResult": case "AverageTimeResult": result.add("new " + opResName + "(ResultRole.SECONDARY, \"" + ops + "\", " + auxAccessors.get(method.getName() + ops) + ", res.getTime(), benchmarkParams.getTimeUnit())"); break; case "SampleTimeResult": case "SingleShotResult": // Not handled. break; default: throw new GenerationException("Unknown result name for @" + AuxCounters.class + ": " + opResName, method); } break; case EVENTS: result.add("new ScalarResult(\"" + ops + "\", " + auxAccessors.get(method.getName() + ops) + ", \"#\", AggregationPolicy.SUM)"); break; default: throw new GenerationException("Unknown @" + AuxCounters.class + " type: " + type, method); } } return result; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/infra/000077500000000000000000000000001446271450100224645ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java000066400000000000000000000403301446271450100263650ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.infra; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.runner.WorkloadParams; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Utils; import org.openjdk.jmh.util.Version; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.concurrent.TimeUnit; /** * Benchmark parameters. * *

{@link BenchmarkParams} handles the parameters used in the current run.

*

This class is dual-purpose:

*
    *
  1. It acts as the interface between host JVM and forked JVM, so that the latter * would not have to figure out the benchmark configuration again
  2. *
  3. It can be injected into benchmark methods to access the runtime configuration * info about the benchmark
  4. *
*/ public class BenchmarkParams extends BenchmarkParamsL4 { private static final long serialVersionUID = -1068219503090299117L; /** * Do the class hierarchy trick to evade false sharing, and check if it's working in runtime. * @see org.openjdk.jmh.infra.Blackhole description for the rationale */ static { Utils.check(BenchmarkParams.class, "benchmark", "generatedTarget", "synchIterations"); Utils.check(BenchmarkParams.class, "threads", "threadGroups", "forks", "warmupForks"); Utils.check(BenchmarkParams.class, "warmup", "measurement"); Utils.check(BenchmarkParams.class, "mode", "params"); Utils.check(BenchmarkParams.class, "timeUnit", "opsPerInvocation"); Utils.check(BenchmarkParams.class, "jvm", "jvmArgs"); } public BenchmarkParams(String benchmark, String generatedTarget, boolean synchIterations, int threads, int[] threadGroups, Collection threadGroupLabels, int forks, int warmupForks, IterationParams warmup, IterationParams measurement, Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, String jdkVersion, String vmName, String vmVersion, String jmhVersion, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, threads, threadGroups, threadGroupLabels, forks, warmupForks, warmup, measurement, mode, params, timeUnit, opsPerInvocation, jvm, jvmArgs, jdkVersion, vmName, vmVersion, jmhVersion, timeout); } } abstract class BenchmarkParamsL4 extends BenchmarkParamsL3 { private static final long serialVersionUID = -2409216922027695385L; private int markerEnd; public BenchmarkParamsL4(String benchmark, String generatedTarget, boolean synchIterations, int threads, int[] threadGroups, Collection threadGroupLabels, int forks, int warmupForks, IterationParams warmup, IterationParams measurement, Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, String jdkVersion, String vmName, String vmVersion, String jmhVersion, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, threads, threadGroups, threadGroupLabels, forks, warmupForks, warmup, measurement, mode, params, timeUnit, opsPerInvocation, jvm, jvmArgs, jdkVersion, vmName, vmVersion, jmhVersion, timeout); } } abstract class BenchmarkParamsL3 extends BenchmarkParamsL2 { private static final long serialVersionUID = -53511295235994554L; private boolean q001, q002, q003, q004, q005, q006, q007, q008; private boolean q011, q012, q013, q014, q015, q016, q017, q018; private boolean q021, q022, q023, q024, q025, q026, q027, q028; private boolean q031, q032, q033, q034, q035, q036, q037, q038; private boolean q041, q042, q043, q044, q045, q046, q047, q048; private boolean q051, q052, q053, q054, q055, q056, q057, q058; private boolean q061, q062, q063, q064, q065, q066, q067, q068; private boolean q071, q072, q073, q074, q075, q076, q077, q078; private boolean q101, q102, q103, q104, q105, q106, q107, q108; private boolean q111, q112, q113, q114, q115, q116, q117, q118; private boolean q121, q122, q123, q124, q125, q126, q127, q128; private boolean q131, q132, q133, q134, q135, q136, q137, q138; private boolean q141, q142, q143, q144, q145, q146, q147, q148; private boolean q151, q152, q153, q154, q155, q156, q157, q158; private boolean q161, q162, q163, q164, q165, q166, q167, q168; private boolean q171, q172, q173, q174, q175, q176, q177, q178; public BenchmarkParamsL3(String benchmark, String generatedTarget, boolean synchIterations, int threads, int[] threadGroups, Collection threadGroupLabels, int forks, int warmupForks, IterationParams warmup, IterationParams measurement, Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, String jdkVersion, String vmName, String vmVersion, String jmhVersion, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, threads, threadGroups, threadGroupLabels, forks, warmupForks, warmup, measurement, mode, params, timeUnit, opsPerInvocation, jvm, jvmArgs, jdkVersion, vmName, vmVersion, jmhVersion, timeout); } } abstract class BenchmarkParamsL1 extends BenchmarkParamsL0 { private boolean p001, p002, p003, p004, p005, p006, p007, p008; private boolean p011, p012, p013, p014, p015, p016, p017, p018; private boolean p021, p022, p023, p024, p025, p026, p027, p028; private boolean p031, p032, p033, p034, p035, p036, p037, p038; private boolean p041, p042, p043, p044, p045, p046, p047, p048; private boolean p051, p052, p053, p054, p055, p056, p057, p058; private boolean p061, p062, p063, p064, p065, p066, p067, p068; private boolean p071, p072, p073, p074, p075, p076, p077, p078; private boolean p101, p102, p103, p104, p105, p106, p107, p108; private boolean p111, p112, p113, p114, p115, p116, p117, p118; private boolean p121, p122, p123, p124, p125, p126, p127, p128; private boolean p131, p132, p133, p134, p135, p136, p137, p138; private boolean p141, p142, p143, p144, p145, p146, p147, p148; private boolean p151, p152, p153, p154, p155, p156, p157, p158; private boolean p161, p162, p163, p164, p165, p166, p167, p168; private boolean p171, p172, p173, p174, p175, p176, p177, p178; } abstract class BenchmarkParamsL0 { private int markerBegin; } abstract class BenchmarkParamsL2 extends BenchmarkParamsL1 implements Serializable, Comparable { private static final long serialVersionUID = -1068219503090299117L; protected final String benchmark; protected final String generatedTarget; protected final boolean synchIterations; protected final int threads; protected final int[] threadGroups; protected final Collection threadGroupLabels; protected final int forks; protected final int warmupForks; protected final IterationParams warmup; protected final IterationParams measurement; protected final Mode mode; protected final WorkloadParams params; protected final TimeUnit timeUnit; protected final int opsPerInvocation; protected final String jvm; protected final Collection jvmArgs; protected final String jdkVersion; protected final String jmhVersion; protected final String vmName; protected final String vmVersion; protected final TimeValue timeout; public BenchmarkParamsL2(String benchmark, String generatedTarget, boolean synchIterations, int threads, int[] threadGroups, Collection threadGroupLabels, int forks, int warmupForks, IterationParams warmup, IterationParams measurement, Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, String jdkVersion, String vmName, String vmVersion, String jmhVersion, TimeValue timeout) { this.benchmark = benchmark; this.generatedTarget = generatedTarget; this.synchIterations = synchIterations; this.threads = threads; this.threadGroups = threadGroups; this.threadGroupLabels = threadGroupLabels; this.forks = forks; this.warmupForks = warmupForks; this.warmup = warmup; this.measurement = measurement; this.mode = mode; this.params = params; this.timeUnit = timeUnit; this.opsPerInvocation = opsPerInvocation; this.jvm = jvm; this.jvmArgs = jvmArgs; this.jdkVersion = jdkVersion; this.vmName = vmName; this.vmVersion = vmVersion; this.jmhVersion = jmhVersion; this.timeout = timeout; } /** * @return how long to wait for iteration to complete */ public TimeValue getTimeout() { return timeout; } /** * @return do we synchronize iterations? */ public boolean shouldSynchIterations() { return synchIterations; } /** * @return iteration parameters for warmup phase */ public IterationParams getWarmup() { return warmup; } /** * @return iteration parameters for measurement phase */ public IterationParams getMeasurement() { return measurement; } /** * @return total measurement thread count */ public int getThreads() { return threads; } /** * @return thread distribution within the group * @see org.openjdk.jmh.runner.options.ChainedOptionsBuilder#threadGroups(int...) */ public int[] getThreadGroups() { return Arrays.copyOf(threadGroups, threadGroups.length); } /** * @return subgroup thread labels * @see #getThreadGroups() */ public Collection getThreadGroupLabels() { return Collections.unmodifiableCollection(threadGroupLabels); } /** * @return number of forked VM runs, which we measure */ public int getForks() { return forks; } /** * @return number of forked VM runs, which we discard from the result */ public int getWarmupForks() { return warmupForks; } /** * @return benchmark mode */ public Mode getMode() { return mode; } /** * @return benchmark name */ public String getBenchmark() { return benchmark; } /** * @return timeUnit used in results */ public TimeUnit getTimeUnit() { return timeUnit; } /** * @return operations per invocation used */ public int getOpsPerInvocation() { return opsPerInvocation; } /** * @return all workload parameters */ public Collection getParamsKeys() { return params.keys(); } /** * @param key parameter key; usually the field name * @return parameter value for given key */ public String getParam(String key) { if (params != null) { return params.get(key); } else { return null; } } /** * @return generated benchmark name */ public String generatedBenchmark() { return generatedTarget; } /** * @return JVM executable path */ public String getJvm() { return jvm; } /** * @return JMH version identical to {@link Version#getPlainVersion()}, but output format should * get there input via bean for testing purposes. */ public String getJmhVersion() { return jmhVersion; } /** * @return JVM options */ public Collection getJvmArgs() { return Collections.unmodifiableCollection(jvmArgs); } /** * @return version information as returned by the effective target JVM, * via system property {@code java.version} and {@code java.vm.version} */ public String getJdkVersion() { return jdkVersion; } /** * @return version information as returned by the effective target JVM, * via system property {@code java.vm.version} */ public String getVmVersion() { return vmVersion; } /** * @return name information as returned by the effective target JVM, * via system property {@code java.vm.name} */ public String getVmName() { return vmName; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; BenchmarkParams that = (BenchmarkParams) o; if (!benchmark.equals(that.benchmark)) return false; if (mode != that.mode) return false; if (!params.equals(that.params)) return false; return true; } @Override public int hashCode() { int result = benchmark.hashCode(); result = 31 * result + mode.hashCode(); result = 31 * result + params.hashCode(); return result; } @Override public int compareTo(BenchmarkParams o) { int v = mode.compareTo(o.mode); if (v != 0) { return v; } int v1 = benchmark.compareTo(o.benchmark); if (v1 != 0) { return v1; } if (params == null || o.params == null) { return 0; } return params.compareTo(o.params); } public String id() { StringBuilder sb = new StringBuilder(); appendSanitized(sb, benchmark); sb.append("-"); sb.append(mode); for (String key : params.keys()) { sb.append("-"); appendSanitized(sb, key); sb.append("-"); appendSanitized(sb, params.get(key)); } return sb.toString(); } private static void appendSanitized(StringBuilder builder, String s) { try { builder.append(URLEncoder.encode(s, "UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java000066400000000000000000000556531446271450100252310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.infra; import org.openjdk.jmh.util.Utils; import java.lang.ref.WeakReference; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Random; /* See the rationale for BlackholeL1..BlackholeL4 classes below. */ abstract class BlackholeL0 { private int markerBegin; } abstract class BlackholeL1 extends BlackholeL0 { private boolean p001, p002, p003, p004, p005, p006, p007, p008; private boolean p011, p012, p013, p014, p015, p016, p017, p018; private boolean p021, p022, p023, p024, p025, p026, p027, p028; private boolean p031, p032, p033, p034, p035, p036, p037, p038; private boolean p041, p042, p043, p044, p045, p046, p047, p048; private boolean p051, p052, p053, p054, p055, p056, p057, p058; private boolean p061, p062, p063, p064, p065, p066, p067, p068; private boolean p071, p072, p073, p074, p075, p076, p077, p078; private boolean p101, p102, p103, p104, p105, p106, p107, p108; private boolean p111, p112, p113, p114, p115, p116, p117, p118; private boolean p121, p122, p123, p124, p125, p126, p127, p128; private boolean p131, p132, p133, p134, p135, p136, p137, p138; private boolean p141, p142, p143, p144, p145, p146, p147, p148; private boolean p151, p152, p153, p154, p155, p156, p157, p158; private boolean p161, p162, p163, p164, p165, p166, p167, p168; private boolean p171, p172, p173, p174, p175, p176, p177, p178; } abstract class BlackholeL2 extends BlackholeL1 { public volatile byte b1; public volatile boolean bool1; public volatile char c1; public volatile short s1; public volatile int i1; public volatile long l1; public volatile float f1; public volatile double d1; public byte b2; public boolean bool2; public char c2; public short s2; public int i2; public long l2; public float f2; public double d2; public volatile Object obj1; public volatile BlackholeL2 nullBait = null; public int tlr; public volatile int tlrMask; public BlackholeL2() { Random r = new Random(System.nanoTime()); tlr = r.nextInt(); tlrMask = 1; obj1 = new Object(); b1 = (byte) r.nextInt(); b2 = (byte) (b1 + 1); bool1 = r.nextBoolean(); bool2 = !bool1; c1 = (char) r.nextInt(); c2 = (char) (c1 + 1); s1 = (short) r.nextInt(); s2 = (short) (s1 + 1); i1 = r.nextInt(); i2 = i1 + 1; l1 = r.nextLong(); l2 = l1 + 1; f1 = r.nextFloat(); f2 = f1 + Math.ulp(f1); d1 = r.nextDouble(); d2 = d1 + Math.ulp(d1); if (b1 == b2) { throw new IllegalStateException("byte tombstones are equal"); } if (bool1 == bool2) { throw new IllegalStateException("boolean tombstones are equal"); } if (c1 == c2) { throw new IllegalStateException("char tombstones are equal"); } if (s1 == s2) { throw new IllegalStateException("short tombstones are equal"); } if (i1 == i2) { throw new IllegalStateException("int tombstones are equal"); } if (l1 == l2) { throw new IllegalStateException("long tombstones are equal"); } if (f1 == f2) { throw new IllegalStateException("float tombstones are equal"); } if (d1 == d2) { throw new IllegalStateException("double tombstones are equal"); } } } abstract class BlackholeL3 extends BlackholeL2 { private boolean q001, q002, q003, q004, q005, q006, q007, q008; private boolean q011, q012, q013, q014, q015, q016, q017, q018; private boolean q021, q022, q023, q024, q025, q026, q027, q028; private boolean q031, q032, q033, q034, q035, q036, q037, q038; private boolean q041, q042, q043, q044, q045, q046, q047, q048; private boolean q051, q052, q053, q054, q055, q056, q057, q058; private boolean q061, q062, q063, q064, q065, q066, q067, q068; private boolean q071, q072, q073, q074, q075, q076, q077, q078; private boolean q101, q102, q103, q104, q105, q106, q107, q108; private boolean q111, q112, q113, q114, q115, q116, q117, q118; private boolean q121, q122, q123, q124, q125, q126, q127, q128; private boolean q131, q132, q133, q134, q135, q136, q137, q138; private boolean q141, q142, q143, q144, q145, q146, q147, q148; private boolean q151, q152, q153, q154, q155, q156, q157, q158; private boolean q161, q162, q163, q164, q165, q166, q167, q168; private boolean q171, q172, q173, q174, q175, q176, q177, q178; } abstract class BlackholeL4 extends BlackholeL3 { private int markerEnd; } /** * Black Hole. * *

Black hole "consumes" the values, conceiving no information to JIT whether the * value is actually used afterwards. This can save from the dead-code elimination * of the computations resulting in the given values.

*/ public final class Blackhole extends BlackholeL4 { /* * IMPLEMENTATION NOTES: * * The major things to dodge with Blackholes are: * * a) Dead-code elimination: the arguments should be used on every call, * so that compilers are unable to fold them into constants or * otherwise optimize them away along with the computations resulted * in them. * * b) False sharing: reading/writing the state may disturb the cache * lines. We need to isolate the critical fields to achieve tolerable * performance. * * c) Write wall: we need to ease off on writes as much as possible, * since it disturbs the caches, pollutes the write buffers, etc. * This may very well result in hitting the memory wall prematurely. * Reading memory is fine as long as it is cacheable. * * To achieve these goals, we are piggybacking on several things in the * compilers: * * 1. Superclass fields are not reordered with the subclass' fields. * No practical VM that we are aware of is doing this. It is unpractical, * because if the superclass fields are at the different offsets in two * subclasses, the VMs would then need to do the polymorphic access for * the superclass fields. * * 2. Compilers are unable to predict the value of the volatile read. * While the compilers can speculatively optimize until the relevant * volatile write happens, it is unlikely to be practical to be able to stop * all the threads the instant that write had happened. * * 3. Compilers' code motion usually respects data dependencies, and they would * not normally schedule the consumer block before the code that generated * a value. * * 4. Compilers are not doing aggressive inter-procedural optimizations, * and/or break them when the target method is forced to be non-inlineable. * * Observation (1) allows us to "squash" the protected fields in the inheritance * hierarchy so that the padding in super- and sub-class are laid out right before * and right after the protected fields. We also pad with booleans so that dense * layout in superclass does not have the gap where runtime can fit the subclass field. * * Observation (2) allows us to compare the incoming primitive values against * the relevant volatile-guarded fields. The values in those guarded fields are * never changing, but due to (2), we should re-read the values again and again. * Also, observation (3) requires us to to use the incoming value in the computation, * thus anchoring the Blackhole code after the generating expression. * * Primitives are a bit hard, because we can't predict what values we * will be fed. But we can compare the incoming value with *two* distinct * known values, and both checks will never be true at the same time. * Note the bitwise AND in all the predicates: both to spare additional * branch, and also to provide more uniformity in the performance. Where possible, * we are using a specific code shape to force generating a single branch, e.g. * making compiler to evaluate the predicate in full, not speculate on components. * * Objects should normally abide the Java's referential semantics, i.e. the * incoming objects will never be equal to the distinct object we have, and * volatile read will break the speculation about what we compare with. * However, smart compilers may deduce that the distinct non-escaped object * on the other side is not equal to anything we have, and fold the comparison * to "false". We do inlined thread-local random to get those objects escaped * with infinitesimal probability. Then again, smart compilers may skip from * generating the slow path, and apply the previous logic to constant-fold * the condition to "false". We are warming up the slow-path in the beginning * to evade that effect. Some caution needs to be exercised not to retain the * captured objects forever: this is normally achieved by calling evaporate() * regularly, but we also additionally protect with retaining the object on * weak reference (contrary to phantom-ref, publishing object still has to * happen, because reference users might need to discover the object). * * Observation (4) provides us with an opportunity to create a safety net in case * either (1), (2) or (3) fails. This is why Blackhole methods are prohibited from * being inlined. This is treated specially in JMH runner code (see CompilerHints). * Conversely, both (1), (2), (3) are covering in case (4) fails. This provides * a defense in depth for Blackhole implementation, where a point failure is a * performance nuisance, but not a correctness catastrophe. * * In all cases, consumes do the volatile reads to have a consistent memory * semantics across all consume methods. * * There is an experimental compiler support for Blackholes that instructs compilers * to treat specific methods as blackholes: keeping their arguments alive. At some * point in the future, we hope to switch to that mode by default, thus greatly * simplifying the Blackhole code. * * An utmost caution should be exercised when changing the Blackhole code. Nominally, * the JMH Core Benchmarks should be run on multiple platforms (and their generated code * examined) to check the effects are still in place, and the overheads are not prohibitive. * Or, in other words: * * IMPLEMENTING AN EFFICIENT / CORRECT BLACKHOLE IS NOT A SIMPLE TASK YOU CAN * DO OVERNIGHT. IT REQUIRES A SIGNIFICANT JVM/COMPILER/PERFORMANCE EXPERTISE, * AND LOTS OF TIME OVER THAT. ADJUST YOUR PLANS ACCORDINGLY. */ private static final boolean COMPILER_BLACKHOLE; static { COMPILER_BLACKHOLE = AccessController.doPrivileged(new PrivilegedAction() { public Boolean run() { return Boolean.getBoolean("compilerBlackholesEnabled"); } }); Utils.check(Blackhole.class, "b1", "b2"); Utils.check(Blackhole.class, "bool1", "bool2"); Utils.check(Blackhole.class, "c1", "c2"); Utils.check(Blackhole.class, "s1", "s2"); Utils.check(Blackhole.class, "i1", "i2"); Utils.check(Blackhole.class, "l1", "l2"); Utils.check(Blackhole.class, "f1", "f2"); Utils.check(Blackhole.class, "d1", "d2"); Utils.check(Blackhole.class, "obj1"); } public Blackhole(String challengeResponse) { /* * Prevent instantiation by user code. Without additional countermeasures * to properly escape Blackhole, its magic is not working. The instances * of Blackholes which are injected into benchmark methods are treated by JMH, * and users are supposed to only use the injected instances. * * It only *seems* simple to make the constructor non-public, but then * there is a lot of infrastructure code which assumes @State has a default * constructor. One might suggest doing the internal factory method to instantiate, * but that does not help when extending the Blackhole. There is a *messy* way to * special-case most of these problems within the JMH code, but it does not seem * to worth the effort. * * Therefore, we choose to fail at runtime. It will only affect the users who thought * "new Blackhole()" is a good idea, and these users are rare. If you are reading this * comment, you might be one of those users. Stay cool! Don't instantiate Blackholes * directly though. */ if (!challengeResponse.equals("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.")) { throw new IllegalStateException("Blackholes should not be instantiated directly."); } } /** * Make any consumed data begone. * * WARNING: This method should only be called by the infrastructure code, in clearly understood cases. * Even though it is public, it is not supposed to be called by users. * * @param challengeResponse arbitrary string */ public void evaporate(String challengeResponse) { if (!challengeResponse.equals("Yes, I am Stephen Hawking, and know a thing or two about black holes.")) { throw new IllegalStateException("Who are you?"); } obj1 = null; } /** * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. * * @param obj object to consume. */ public final void consume(Object obj) { if (COMPILER_BLACKHOLE) { consumeCompiler(obj); } else { consumeFull(obj); } } /** * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. * * @param b object to consume. */ public final void consume(byte b) { if (COMPILER_BLACKHOLE) { consumeCompiler(b); } else { consumeFull(b); } } /** * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. * * @param bool object to consume. */ public final void consume(boolean bool) { if (COMPILER_BLACKHOLE) { consumeCompiler(bool); } else { consumeFull(bool); } } /** * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. * * @param c object to consume. */ public final void consume(char c) { if (COMPILER_BLACKHOLE) { consumeCompiler(c); } else { consumeFull(c); } } /** * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. * * @param s object to consume. */ public final void consume(short s) { if (COMPILER_BLACKHOLE) { consumeCompiler(s); } else { consumeFull(s); } } /** * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. * * @param i object to consume. */ public final void consume(int i) { if (COMPILER_BLACKHOLE) { consumeCompiler(i); } else { consumeFull(i); } } /** * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. * * @param l object to consume. */ public final void consume(long l) { if (COMPILER_BLACKHOLE) { consumeCompiler(l); } else { consumeFull(l); } } /** * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. * * @param f object to consume. */ public final void consume(float f) { if (COMPILER_BLACKHOLE) { consumeCompiler(f); } else { consumeFull(f); } } /** * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. * * @param d object to consume. */ public final void consume(double d) { if (COMPILER_BLACKHOLE) { consumeCompiler(d); } else { consumeFull(d); } } // Compiler blackholes block: let compilers figure out how to deal with it. private static void consumeCompiler(boolean v) {} private static void consumeCompiler(byte v) {} private static void consumeCompiler(short v) {} private static void consumeCompiler(char v) {} private static void consumeCompiler(int v) {} private static void consumeCompiler(float v) {} private static void consumeCompiler(double v) {} private static void consumeCompiler(long v) {} private static void consumeCompiler(Object v) {} // Full blackholes block: confuse compilers to get blackholing effects. // See implementation comments at the top to understand what this code is doing. private void consumeFull(byte b) { byte b1 = this.b1; // volatile read byte b2 = this.b2; if ((b ^ b1) == (b ^ b2)) { // SHOULD NEVER HAPPEN nullBait.b1 = b; // implicit null pointer exception } } private void consumeFull(boolean bool) { boolean bool1 = this.bool1; // volatile read boolean bool2 = this.bool2; if ((bool ^ bool1) == (bool ^ bool2)) { // SHOULD NEVER HAPPEN nullBait.bool1 = bool; // implicit null pointer exception } } private void consumeFull(char c) { char c1 = this.c1; // volatile read char c2 = this.c2; if ((c ^ c1) == (c ^ c2)) { // SHOULD NEVER HAPPEN nullBait.c1 = c; // implicit null pointer exception } } private void consumeFull(short s) { short s1 = this.s1; // volatile read short s2 = this.s2; if ((s ^ s1) == (s ^ s2)) { // SHOULD NEVER HAPPEN nullBait.s1 = s; // implicit null pointer exception } } private void consumeFull(int i) { int i1 = this.i1; // volatile read int i2 = this.i2; if ((i ^ i1) == (i ^ i2)) { // SHOULD NEVER HAPPEN nullBait.i1 = i; // implicit null pointer exception } } private void consumeFull(long l) { long l1 = this.l1; // volatile read long l2 = this.l2; if ((l ^ l1) == (l ^ l2)) { // SHOULD NEVER HAPPEN nullBait.l1 = l; // implicit null pointer exception } } private void consumeFull(float f) { float f1 = this.f1; // volatile read float f2 = this.f2; if (f == f1 & f == f2) { // SHOULD NEVER HAPPEN nullBait.f1 = f; // implicit null pointer exception } } private void consumeFull(double d) { double d1 = this.d1; // volatile read double d2 = this.d2; if (d == d1 & d == d2) { // SHOULD NEVER HAPPEN nullBait.d1 = d; // implicit null pointer exception } } private void consumeFull(Object obj) { int tlrMask = this.tlrMask; // volatile read int tlr = (this.tlr = (this.tlr * 1664525 + 1013904223)); if ((tlr & tlrMask) == 0) { // SHOULD ALMOST NEVER HAPPEN IN MEASUREMENT this.obj1 = new WeakReference<>(obj); this.tlrMask = (tlrMask << 1) + 1; } } private static volatile long consumedCPU = System.nanoTime(); /** * Consume some amount of time tokens. * * This method does the CPU work almost linear to the number of tokens. * The token cost may vary from system to system, and may change in * future. (Translation: it is as reliable as we can get, but not absolutely * reliable). * * See JMH samples for the complete demo, and core benchmarks for * the performance assessments. * * @param tokens CPU tokens to consume */ public static void consumeCPU(long tokens) { // If you are looking at this code trying to understand // the non-linearity on low token counts, know this: // we are pretty sure the generated assembly for almost all // cases is the same, and the only explanation for the // performance difference is hardware-specific effects. // Be wary to waste more time on this. If you know more // advanced and clever option to implement consumeCPU, let us // know. // Randomize start so that JIT could not memoize; this helps // to break the loop optimizations if the method is called // from the external loop body. long t = consumedCPU; // One of the rare cases when counting backwards is meaningful: // for the forward loop HotSpot/x86 generates "cmp" with immediate // on the hot path, while the backward loop tests against zero // with "test". The immediate can have different lengths, which // attribute to different machine code for different cases. We // counter that with always counting backwards. We also mix the // induction variable in, so that reversing the loop is the // non-trivial optimization. for (long i = tokens; i > 0; i--) { t += (t * 0x5DEECE66DL + 0xBL + i) & (0xFFFFFFFFFFFFL); } // Need to guarantee side-effect on the result, but can't afford // contention; make sure we update the shared state only in the // unlikely case, so not to do the furious writes, but still // dodge DCE. if (t == 42) { consumedCPU += t; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/infra/Control.java000066400000000000000000000107361446271450100247560ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.infra; import org.openjdk.jmh.util.Utils; /** * Control object, used to communicate significant information from JMH to the benchmark. * WARNING: The API for this class is considered unstable, and can be changed without notice. */ public final class Control extends ControlL4 { /** * Do the class hierarchy trick to evade false sharing, and check if it's working in runtime. * @see org.openjdk.jmh.infra.Blackhole description for the rationale */ static { Utils.check(Control.class, "startMeasurement", "stopMeasurement"); } } abstract class ControlL0 { private int markerBegin; } abstract class ControlL1 extends ControlL0 { private boolean p001, p002, p003, p004, p005, p006, p007, p008; private boolean p011, p012, p013, p014, p015, p016, p017, p018; private boolean p021, p022, p023, p024, p025, p026, p027, p028; private boolean p031, p032, p033, p034, p035, p036, p037, p038; private boolean p041, p042, p043, p044, p045, p046, p047, p048; private boolean p051, p052, p053, p054, p055, p056, p057, p058; private boolean p061, p062, p063, p064, p065, p066, p067, p068; private boolean p071, p072, p073, p074, p075, p076, p077, p078; private boolean p101, p102, p103, p104, p105, p106, p107, p108; private boolean p111, p112, p113, p114, p115, p116, p117, p118; private boolean p121, p122, p123, p124, p125, p126, p127, p128; private boolean p131, p132, p133, p134, p135, p136, p137, p138; private boolean p141, p142, p143, p144, p145, p146, p147, p148; private boolean p151, p152, p153, p154, p155, p156, p157, p158; private boolean p161, p162, p163, p164, p165, p166, p167, p168; private boolean p171, p172, p173, p174, p175, p176, p177, p178; } abstract class ControlL2 extends ControlL1 { /** * Transitions to "true", once JMH had started the measurement for the current iteration. */ public volatile boolean startMeasurement; /** * Transitions to "true", once JMH is stopping the measurement for the current iteration */ public volatile boolean stopMeasurement; } abstract class ControlL3 extends ControlL2 { private boolean q001, q002, q003, q004, q005, q006, q007, q008; private boolean q011, q012, q013, q014, q015, q016, q017, q018; private boolean q021, q022, q023, q024, q025, q026, q027, q028; private boolean q031, q032, q033, q034, q035, q036, q037, q038; private boolean q041, q042, q043, q044, q045, q046, q047, q048; private boolean q051, q052, q053, q054, q055, q056, q057, q058; private boolean q061, q062, q063, q064, q065, q066, q067, q068; private boolean q071, q072, q073, q074, q075, q076, q077, q078; private boolean q101, q102, q103, q104, q105, q106, q107, q108; private boolean q111, q112, q113, q114, q115, q116, q117, q118; private boolean q121, q122, q123, q124, q125, q126, q127, q128; private boolean q131, q132, q133, q134, q135, q136, q137, q138; private boolean q141, q142, q143, q144, q145, q146, q147, q148; private boolean q151, q152, q153, q154, q155, q156, q157, q158; private boolean q161, q162, q163, q164, q165, q166, q167, q168; private boolean q171, q172, q173, q174, q175, q176, q177, q178; } abstract class ControlL4 extends ControlL3 { private int markerEnd; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/infra/IterationParams.java000066400000000000000000000164511446271450100264400ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.infra; import org.openjdk.jmh.runner.IterationType; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Utils; import java.io.Serializable; import java.util.Objects; /** * Iteration parameters. * *

Iteration parameters are separated in at least two instances, with different {@link IterationType}-s. * The complete benchmark parameters not specific for a particular iteration are available in * {@link org.openjdk.jmh.infra.BenchmarkParams}.

*

This class is dual-purpose:

*
    *
  1. It acts as the interface between host JVM and forked JVM, so that the latter * would not have to figure out the benchmark configuration again
  2. *
  3. It can be injected into benchmark methods to access the runtime configuration * info about the benchmark
  4. *
*/ public final class IterationParams extends IterationParamsL4 { private static final long serialVersionUID = -8111111319033802892L; static { Utils.check(IterationParams.class, "type", "count", "timeValue", "batchSize"); } public IterationParams(IterationType type, int count, TimeValue time, int batchSize) { super(type, count, time, batchSize); } } abstract class IterationParamsL4 extends IterationParamsL3 { private static final long serialVersionUID = 9079354621906758255L; private int markerEnd; public IterationParamsL4(IterationType type, int count, TimeValue time, int batchSize) { super(type, count, time, batchSize); } } abstract class IterationParamsL3 extends IterationParamsL2 { private static final long serialVersionUID = 3907464940104879178L; private boolean q001, q002, q003, q004, q005, q006, q007, q008; private boolean q011, q012, q013, q014, q015, q016, q017, q018; private boolean q021, q022, q023, q024, q025, q026, q027, q028; private boolean q031, q032, q033, q034, q035, q036, q037, q038; private boolean q041, q042, q043, q044, q045, q046, q047, q048; private boolean q051, q052, q053, q054, q055, q056, q057, q058; private boolean q061, q062, q063, q064, q065, q066, q067, q068; private boolean q071, q072, q073, q074, q075, q076, q077, q078; private boolean q101, q102, q103, q104, q105, q106, q107, q108; private boolean q111, q112, q113, q114, q115, q116, q117, q118; private boolean q121, q122, q123, q124, q125, q126, q127, q128; private boolean q131, q132, q133, q134, q135, q136, q137, q138; private boolean q141, q142, q143, q144, q145, q146, q147, q148; private boolean q151, q152, q153, q154, q155, q156, q157, q158; private boolean q161, q162, q163, q164, q165, q166, q167, q168; private boolean q171, q172, q173, q174, q175, q176, q177, q178; public IterationParamsL3(IterationType type, int count, TimeValue time, int batchSize) { super(type, count, time, batchSize); } } abstract class IterationParamsL1 extends IterationParamsL0 { private boolean p001, p002, p003, p004, p005, p006, p007, p008; private boolean p011, p012, p013, p014, p015, p016, p017, p018; private boolean p021, p022, p023, p024, p025, p026, p027, p028; private boolean p031, p032, p033, p034, p035, p036, p037, p038; private boolean p041, p042, p043, p044, p045, p046, p047, p048; private boolean p051, p052, p053, p054, p055, p056, p057, p058; private boolean p061, p062, p063, p064, p065, p066, p067, p068; private boolean p071, p072, p073, p074, p075, p076, p077, p078; private boolean p101, p102, p103, p104, p105, p106, p107, p108; private boolean p111, p112, p113, p114, p115, p116, p117, p118; private boolean p121, p122, p123, p124, p125, p126, p127, p128; private boolean p131, p132, p133, p134, p135, p136, p137, p138; private boolean p141, p142, p143, p144, p145, p146, p147, p148; private boolean p151, p152, p153, p154, p155, p156, p157, p158; private boolean p161, p162, p163, p164, p165, p166, p167, p168; private boolean p171, p172, p173, p174, p175, p176, p177, p178; } abstract class IterationParamsL0 { private int markerBegin; } abstract class IterationParamsL2 extends IterationParamsL1 implements Serializable { private static final long serialVersionUID = -6138850517953881052L; /** * iteration type */ protected final IterationType type; /** * amount of iterations */ protected final int count; /** * iteration runtime */ protected final TimeValue timeValue; /** * batch size (method invocations inside the single op) */ protected final int batchSize; public IterationParamsL2(IterationType type, int count, TimeValue time, int batchSize) { this.type = type; this.count = count; this.timeValue = time; this.batchSize = batchSize; } /** * Iteration type: separates warmup iterations vs. measurement iterations. * @return iteration type. */ public IterationType getType() { return type; } /** * Number of iterations. * @return number of iterations of given type. */ public int getCount() { return count; } /** * Time for iteration. * @return time */ public TimeValue getTime() { return timeValue; } /** * Batch size for iteration. * @return batch size */ public int getBatchSize() { return batchSize; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; IterationParams that = (IterationParams) o; if (count != that.count) return false; if (batchSize != that.batchSize) return false; if (!Objects.equals(timeValue, that.timeValue)) return false; return true; } @Override public int hashCode() { int result = count; result = 31 * result + batchSize; result = 31 * result + (timeValue != null ? timeValue.hashCode() : 0); return result; } @Override public String toString() { return "IterationParams("+ getCount()+", "+ getTime()+", "+ getBatchSize()+")"; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/infra/ThreadParams.java000066400000000000000000000267361446271450100257200ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.infra; import org.openjdk.jmh.util.Utils; /** * Thread parameters. * *

Thread parameters handle the infrastructure info about the threading, including but * not limited to the number of threads, thread indicies, group information, etc. Some * of that info duplicates what is available in {@link org.openjdk.jmh.infra.BenchmarkParams}.

*/ public final class ThreadParams extends ThreadParamsL4 { public ThreadParams(int threadIdx, int threadCount, int groupIdx, int groupCount, int subgroupIdx, int subgroupCount, int groupThreadIdx, int groupThreadCount, int subgroupThreadIdx, int subgroupThreadCount) { super(threadIdx, threadCount, groupIdx, groupCount, subgroupIdx, subgroupCount, groupThreadIdx, groupThreadCount, subgroupThreadIdx, subgroupThreadCount); } static { Utils.check(ThreadParams.class, "threadIdx", "threadCount"); Utils.check(ThreadParams.class, "groupIdx", "groupCount"); Utils.check(ThreadParams.class, "subgroupIdx", "subgroupCount"); Utils.check(ThreadParams.class, "groupThreadIdx", "groupThreadCount"); Utils.check(ThreadParams.class, "subgroupThreadIdx", "subgroupThreadCount"); } /** * Answers the number of groups in the run. * *

When running the symmetric benchmark, each thread occupies its own group, * and therefore number of groups equals the thread count.

* *

This is a convenience method, similar info can be figured out by dividing * the number of threads ({@link #getThreadCount()}) by the number of threads per * group ({@link #getGroupThreadCount()}).

* * @return number of groups * @see #getThreadCount() */ public int getGroupCount() { return groupCount; } /** * Answers the thread group index. * *

Group indices are having the range of [0..G-1], where G is the number * of thread groups in the run. When running the symmetric benchmark, each * thread occupies its own group, and therefore the group index equals to * the thread index.

* * @return thread group index * @see #getGroupCount() */ public int getGroupIndex() { return groupIdx; } /** * Answers the number of distinct workloads (subgroups) in the current group. * *

When running the symmetric benchmark, each thread occupies its own group, * and therefore number of subgroups equals to one.

* * @return number of subgroups * @see #getThreadCount() */ public int getSubgroupCount() { return subgroupCount; } /** * Answers the subgroup index. * *

Subgroup index enumerates the distinct workloads (subgroups) in current * group. The index the range of [0..S-1], where S is the number of subgroups * in current group. When running the symmetric benchmark, there is only * a single workload in the group, and therefore the subgroup index is zero.

* * @return subgroup index * @see #getSubgroupCount() */ public int getSubgroupIndex() { return subgroupIdx; } /** * Answers the number of threads participating in the run. * *

This is a convenience method, similar info can be queried directly from * {@link org.openjdk.jmh.infra.BenchmarkParams#getThreads()}

* * @return number of threads */ public int getThreadCount() { return threadCount; } /** * Answers the thread index. * *

Thread indices are in range [0..N-1], where N is the number of threads * participating in the run.

* * @return thread index * @see #getThreadCount() */ public int getThreadIndex() { return threadIdx; } /** * Answers the number of threads in the current group. * *

When running the symmetric benchmark, each thread occupies its own group, * and therefore number of subgroups equals to one.

* *

This is a convenience method, similar info can be figured out by summing * up the thread distribution from * {@link org.openjdk.jmh.infra.BenchmarkParams#getThreadGroups()}.

* * @return number of threads in the group * @see #getThreadCount() */ public int getGroupThreadCount() { return groupThreadCount; } /** * Answers the thread sub-index in current group. * *

Subgroup index enumerates the thread within a group, and takes * the range of [0..T-1], where T is the number of threads in current * group. When running the symmetric benchmark, each thread occupies * its own group, and therefore the subgroup index is zero.

* * @return index of thread in the group * @see #getGroupThreadCount() */ public int getGroupThreadIndex() { return groupThreadIdx; } /** * Answers the number of threads in the current subgroup. * *

When running the symmetric benchmark, each thread occupies its own group, * each thread implicitly occupies a single subgroup, and therefore, the number * of subgroups equals to one.

* *

This is a convenience method, similar info can be figured out with * querying {@link org.openjdk.jmh.infra.BenchmarkParams#getThreadGroups()} with * {@link #getSubgroupIndex()} used as index.

* * @return number of threads in subgroup * @see #getThreadCount() */ public int getSubgroupThreadCount() { return subgroupThreadCount; } /** * Answers the thread sub-index in current subgroup. * *

Subgroup index enumerates the thread within a subgroup, and takes * the range of [0..T-1], where T is the number of threads in current * subgroup. When running the symmetric benchmark, each thread occupies * its own group, and therefore the subgroup index is zero.

* * @return index of thread in subgroup * @see #getSubgroupThreadCount() */ public int getSubgroupThreadIndex() { return subgroupThreadIdx; } } abstract class ThreadParamsL0 { private int markerBegin; } abstract class ThreadParamsL1 extends ThreadParamsL0 { private boolean p001, p002, p003, p004, p005, p006, p007, p008; private boolean p011, p012, p013, p014, p015, p016, p017, p018; private boolean p021, p022, p023, p024, p025, p026, p027, p028; private boolean p031, p032, p033, p034, p035, p036, p037, p038; private boolean p041, p042, p043, p044, p045, p046, p047, p048; private boolean p051, p052, p053, p054, p055, p056, p057, p058; private boolean p061, p062, p063, p064, p065, p066, p067, p068; private boolean p071, p072, p073, p074, p075, p076, p077, p078; private boolean p101, p102, p103, p104, p105, p106, p107, p108; private boolean p111, p112, p113, p114, p115, p116, p117, p118; private boolean p121, p122, p123, p124, p125, p126, p127, p128; private boolean p131, p132, p133, p134, p135, p136, p137, p138; private boolean p141, p142, p143, p144, p145, p146, p147, p148; private boolean p151, p152, p153, p154, p155, p156, p157, p158; private boolean p161, p162, p163, p164, p165, p166, p167, p168; private boolean p171, p172, p173, p174, p175, p176, p177, p178; } abstract class ThreadParamsL2 extends ThreadParamsL1 { protected final int threadIdx, threadCount; protected final int groupIdx, groupCount; protected final int subgroupIdx, subgroupCount; protected final int groupThreadIdx, groupThreadCount; protected final int subgroupThreadIdx, subgroupThreadCount; public ThreadParamsL2(int threadIdx, int threadCount, int groupIdx, int groupCount, int subgroupIdx, int subgroupCount, int groupThreadIdx, int groupThreadCount, int subgroupThreadIdx, int subgroupThreadCount) { this.threadIdx = threadIdx; this.threadCount = threadCount; this.groupIdx = groupIdx; this.groupCount = groupCount; this.subgroupIdx = subgroupIdx; this.subgroupCount = subgroupCount; this.groupThreadIdx = groupThreadIdx; this.groupThreadCount = groupThreadCount; this.subgroupThreadIdx = subgroupThreadIdx; this.subgroupThreadCount = subgroupThreadCount; } } abstract class ThreadParamsL3 extends ThreadParamsL2 { private boolean q001, q002, q003, q004, q005, q006, q007, q008; private boolean q011, q012, q013, q014, q015, q016, q017, q018; private boolean q021, q022, q023, q024, q025, q026, q027, q028; private boolean q031, q032, q033, q034, q035, q036, q037, q038; private boolean q041, q042, q043, q044, q045, q046, q047, q048; private boolean q051, q052, q053, q054, q055, q056, q057, q058; private boolean q061, q062, q063, q064, q065, q066, q067, q068; private boolean q071, q072, q073, q074, q075, q076, q077, q078; private boolean q101, q102, q103, q104, q105, q106, q107, q108; private boolean q111, q112, q113, q114, q115, q116, q117, q118; private boolean q121, q122, q123, q124, q125, q126, q127, q128; private boolean q131, q132, q133, q134, q135, q136, q137, q138; private boolean q141, q142, q143, q144, q145, q146, q147, q148; private boolean q151, q152, q153, q154, q155, q156, q157, q158; private boolean q161, q162, q163, q164, q165, q166, q167, q168; private boolean q171, q172, q173, q174, q175, q176, q177, q178; public ThreadParamsL3(int threadIdx, int threadCount, int groupIdx, int groupCount, int subgroupIdx, int subgroupCount, int groupThreadIdx, int groupThreadCount, int subgroupThreadIdx, int subgroupThreadCount) { super(threadIdx, threadCount, groupIdx, groupCount, subgroupIdx, subgroupCount, groupThreadIdx, groupThreadCount, subgroupThreadIdx, subgroupThreadCount); } } abstract class ThreadParamsL4 extends ThreadParamsL3 { private int markerEnd; public ThreadParamsL4(int threadIdx, int threadCount, int groupIdx, int groupCount, int subgroupIdx, int subgroupCount, int groupThreadIdx, int groupThreadCount, int subgroupThreadIdx, int subgroupThreadCount) { super(threadIdx, threadCount, groupIdx, groupCount, subgroupIdx, subgroupCount, groupThreadIdx, groupThreadCount, subgroupThreadIdx, subgroupThreadCount); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/000077500000000000000000000000001446271450100230255ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java000066400000000000000000001562221446271450100304240ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.*; import org.openjdk.jmh.util.*; import java.io.*; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public abstract class AbstractPerfAsmProfiler implements ExternalProfiler { protected final List requestedEventNames; private final double regionRateThreshold; private final int regionShowTop; private final int regionTooBigThreshold; private final int printMargin; private final int mergeMargin; private final boolean mergeMethods; private final int delayMsec; private final int lengthMsec; private final boolean skipAssembly; private final boolean skipInterpreter; private final boolean skipVMStubs; private final boolean savePerfOutput; private final String savePerfOutputTo; private final String savePerfOutputToFile; private final boolean savePerfBin; private final String savePerfBinTo; private final String savePerfBinFile; private final boolean saveLog; private final String saveLogTo; private final String saveLogToFile; private final boolean intelSyntax; protected final TempFile hsLog; protected final TempFile perfBinData; protected final TempFile perfParsedData; protected final OptionSet set; private final boolean drawIntraJumps; private final boolean drawInterJumps; private final ShowCounts showCounts; private enum ShowCounts { raw, norm, percent_total, } protected AbstractPerfAsmProfiler(String initLine, String... events) throws ProfilerException { try { hsLog = FileUtils.weakTempFile("hslog"); perfBinData = FileUtils.weakTempFile("perfbin"); perfParsedData = FileUtils.weakTempFile("perfparsed"); } catch (IOException e) { throw new ProfilerException(e); } OptionParser parser = new OptionParser(); parser.formatHelpWith(new ProfilerOptionFormatter("perfasm")); OptionSpec optEvents = parser.accepts("events", "Events to gather.") .withRequiredArg().ofType(String.class).withValuesSeparatedBy(",").describedAs("event").defaultsTo(events); OptionSpec optThresholdRate = parser.accepts("hotThreshold", "Cutoff threshold for hot regions. The regions with event count over threshold would be expanded " + "with detailed disassembly.") .withRequiredArg().ofType(Double.class).describedAs("rate").defaultsTo(0.10); OptionSpec optShowTop = parser.accepts("top", "Show this number of top hottest code regions.") .withRequiredArg().ofType(Integer.class).describedAs("#").defaultsTo(20); OptionSpec optThreshold = parser.accepts("tooBigThreshold", "Cutoff threshold for large region. The region containing more than this number of lines " + "would be truncated.") .withRequiredArg().ofType(Integer.class).describedAs("lines").defaultsTo(1000); OptionSpec optPrintMargin = parser.accepts("printMargin", "Print margin. How many \"context\" lines without counters to show in each region.") .withRequiredArg().ofType(Integer.class).describedAs("lines").defaultsTo(10); OptionSpec optMergeMargin = parser.accepts("mergeMargin", "Merge margin. The regions separated by less than the margin are merged.") .withRequiredArg().ofType(Integer.class).describedAs("lines").defaultsTo(32); OptionSpec optMergeMethods = parser.accepts("mergeMethods", "Merge all regions from the same method") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSpec optDelay = parser.accepts("delay", "Delay collection for a given time, in milliseconds; -1 to detect automatically.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); OptionSpec optLength = parser.accepts("length", "Do the collection for a given time, in milliseconds; -1 to detect automatically.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); OptionSpec optSkipAsm = parser.accepts("skipAsm", "Skip -XX:+PrintAssembly instrumentation.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSpec optSkipInterpreter = parser.accepts("skipInterpreter", "Skip printing out interpreter stubs. This may improve the parser performance at the expense " + "of missing the resolution and disassembly of interpreter regions.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSpec optSkipVMStubs = parser.accepts("skipVMStubs", "Skip printing out VM stubs. This may improve the parser performance at the expense " + "of missing the resolution and disassembly of VM stub regions.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSpec optPerfOut = parser.accepts("savePerf", "Save parsed perf output to file. Use this for debugging.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSpec optPerfOutTo = parser.accepts("savePerfTo", "Override the parsed perf output log location. This will use the unique file name per test. Use this for debugging.") .withRequiredArg().ofType(String.class).describedAs("dir").defaultsTo("."); OptionSpec optPerfOutToFile = parser.accepts("savePerfToFile", "Override the perf output log filename. Use this for debugging.") .withRequiredArg().ofType(String.class).describedAs("file"); OptionSpec optPerfBin = parser.accepts("savePerfBin", "Save binary perf data to file. Use this for debugging.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSpec optPerfBinTo = parser.accepts("savePerfBinTo", "Override the binary perf data location. This will use the unique file name per test. Use this for debugging.") .withRequiredArg().ofType(String.class).describedAs("dir").defaultsTo("."); OptionSpec optPerfBinToFile = parser.accepts("savePerfBinToFile", "Override the perf binary data filename. Use this for debugging.") .withRequiredArg().ofType(String.class).describedAs("file"); OptionSpec optSaveLog = parser.accepts("saveLog", "Save annotated Hotspot log to file.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSpec optSaveLogTo = parser.accepts("saveLogTo", "Override the annotated Hotspot log location. This will use the unique file name per test.") .withRequiredArg().ofType(String.class).describedAs("dir").defaultsTo("."); OptionSpec optSaveLogToFile = parser.accepts("saveLogToFile", "Override the annotated Hotspot log filename.") .withRequiredArg().ofType(String.class).describedAs("file"); OptionSpec optIntelSyntax = parser.accepts("intelSyntax", "Should perfasm use intel syntax?") .withRequiredArg().ofType(Boolean.class).describedAs("boolean").defaultsTo(false); OptionSpec optDrawIntraJumps = parser.accepts("drawIntraJumps", "Should perfasm draw jump arrows with the region?") .withRequiredArg().ofType(Boolean.class).describedAs("boolean").defaultsTo(true); OptionSpec optDrawInterJumps = parser.accepts("drawInterJumps", "Should perfasm draw jump arrows out of the region?") .withRequiredArg().ofType(Boolean.class).describedAs("boolean").defaultsTo(false); OptionSpec optShowCounts = parser.accepts("showCounts", "How should perfasm show the event counts: " + ShowCounts.raw + " (unaltered), " + ShowCounts.norm + " (normalized to @Benchmark calls), " + ShowCounts.percent_total + " (percent of total events).") .withRequiredArg().ofType(String.class).describedAs("type").defaultsTo(ShowCounts.percent_total.toString()); addMyOptions(parser); set = ProfilerUtils.parseInitLine(initLine, parser); try { requestedEventNames = set.valuesOf(optEvents); regionRateThreshold = set.valueOf(optThresholdRate); regionShowTop = set.valueOf(optShowTop); regionTooBigThreshold = set.valueOf(optThreshold); printMargin = set.valueOf(optPrintMargin); mergeMargin = set.valueOf(optMergeMargin); mergeMethods = set.valueOf(optMergeMethods); delayMsec = set.valueOf(optDelay); lengthMsec = set.valueOf(optLength); skipAssembly = set.valueOf(optSkipAsm); skipInterpreter = set.valueOf(optSkipInterpreter); skipVMStubs = set.valueOf(optSkipVMStubs); savePerfOutput = set.valueOf(optPerfOut); savePerfOutputTo = set.valueOf(optPerfOutTo); savePerfOutputToFile = set.valueOf(optPerfOutToFile); savePerfBin = set.valueOf(optPerfBin); savePerfBinTo = set.valueOf(optPerfBinTo); savePerfBinFile = set.valueOf(optPerfBinToFile); saveLog = set.valueOf(optSaveLog); saveLogTo = set.valueOf(optSaveLogTo); saveLogToFile = set.valueOf(optSaveLogToFile); intelSyntax = set.valueOf(optIntelSyntax); drawIntraJumps = set.valueOf(optDrawInterJumps); drawInterJumps = set.valueOf(optDrawIntraJumps); showCounts = ShowCounts.valueOf(set.valueOf(optShowCounts)); } catch (OptionException | IllegalArgumentException e) { throw new ProfilerException(e.getMessage()); } } protected abstract void addMyOptions(OptionParser parser); @Override public Collection addJVMOptions(BenchmarkParams params) { if (!skipAssembly) { Collection opts = new ArrayList<>(); opts.addAll(Arrays.asList( "-XX:+UnlockDiagnosticVMOptions", "-XX:+LogCompilation", "-XX:LogFile=" + hsLog.getAbsolutePath(), "-XX:+PrintAssembly")); if (!skipInterpreter) { opts.add("-XX:+PrintInterpreter"); } if (!skipVMStubs) { opts.add("-XX:+PrintNMethods"); opts.add("-XX:+PrintNativeNMethods"); opts.add("-XX:+PrintSignatureHandlers"); opts.add("-XX:+PrintAdapterHandlers"); opts.add("-XX:+PrintStubCode"); } if (intelSyntax) { opts.add("-XX:PrintAssemblyOptions=intel"); } return opts; } else { return Collections.emptyList(); } } @Override public void beforeTrial(BenchmarkParams params) { // do nothing } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { TextResult result = processAssembly(br); // we know these are not needed anymore, proactively delete hsLog.delete(); perfBinData.delete(); perfParsedData.delete(); return Collections.singleton(result); } @Override public boolean allowPrintOut() { return false; } @Override public boolean allowPrintErr() { return false; } /** * Parse profiler events from binary to text form. */ protected abstract void parseEvents(); /** * Read parsed events. * * @param skipMs Milliseconds to skip. * @param lenMs Milliseconds to capture after skip * @return Events. */ protected abstract PerfEvents readEvents(double skipMs, double lenMs); /** * Some profilers strip modifiers from event names. * To properly match the events in shared code, we need to know * what those events were stripped to. * @return stripped events */ protected List stripEventNames(List src) { return src; } /** * Get perf binary data extension (optional). * * @return Extension. */ protected abstract String perfBinaryExtension(); private TextResult processAssembly(BenchmarkResult br) { /** * 1. Parse binary events. */ parseEvents(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); /** * 2. Read out PrintAssembly output */ Assembly assembly = readAssembly(hsLog.file()); if (assembly.size() > 0) { pw.printf("PrintAssembly processed: %d total address lines.%n", assembly.size()); } else if (skipAssembly) { pw.println(); pw.println("PrintAssembly skipped, Java methods are not resolved."); pw.println(); } else { pw.println(); pw.println("ERROR: No address lines detected in assembly capture. Make sure your JDK is properly configured to"); pw.println("print generated assembly. The most probable cause for this failure is that hsdis is not available,"); pw.println("or resides at the wrong path within the JDK. Try to run the same JDK with -XX:+PrintAssembly with"); pw.println("a simple non-JMH program and look for warning messages. For details, see the link below:"); pw.println(" https://wiki.openjdk.java.net/display/HotSpot/PrintAssembly"); pw.println(); } /** * 3. Read out perf output */ long skipMs; if (delayMsec == -1) { // not set skipMs = ProfilerUtils.measurementDelayMs(br); } else { skipMs = delayMsec; } double lenMs; if (lengthMsec == -1) { // not set lenMs = ProfilerUtils.measuredTimeMs(br); } else { lenMs = lengthMsec; } final PerfEvents events = readEvents(skipMs, lenMs); List evNames = stripEventNames(requestedEventNames); if (!events.isEmpty()) { pw.printf("Perf output processed (skipped %.3f seconds):%n", skipMs / 1000D); int cnt = 1; for (int i = 0; i < evNames.size(); i++) { String stripped = evNames.get(i); String requested = requestedEventNames.get(i); pw.printf(" Column %d: %s%s (%d events)%n", cnt, stripped, (requested.equals(stripped) ? "" : " (" + requested + ")"), events.get(stripped).size()); cnt++; } pw.println(); } else { pw.println(); pw.println("ERROR: No perf data, make sure \"perf stat echo 1\" is indeed working;\n " + "or the collection delay is not running past the benchmark time."); pw.println(); } PrintContext context; { BenchmarkResultMetaData md = br.getMetadata(); long ops = Math.max(1, md.getMeasurementOps()); int majorScale; int minorScale; switch (showCounts) { case raw: majorScale = 1; minorScale = 0; for (long c : events.totalCounts.values()) { majorScale = Math.max(majorScale, (int)Math.ceil(Math.log10(c))); } break; case norm: majorScale = 2; minorScale = 1; for (long c : events.totalCounts.values()) { double d = Math.log10(1D * c / ops); if (d < 0) { minorScale = Math.max(minorScale, (int)Math.ceil(-d)); } else { majorScale = Math.max(majorScale, (int)Math.ceil(d)); } } break; case percent_total: majorScale = 3; minorScale = 2; break; default: throw new IllegalStateException("Unhandled enum: " + showCounts); } context = new PrintContext(showCounts, ops, majorScale + minorScale + 2, minorScale); } /** * 4. Figure out code regions */ final List regions = makeRegions(assembly, events, context); /** * 5. Figure out interesting regions, and print them out. * We would sort the regions by the hotness of the first (main) event type. */ final String mainEvent = evNames.get(0); regions.sort((o1, o2) -> Long.compare(o2.getEventCount(events, mainEvent), o1.getEventCount(events, mainEvent))); long threshold = (long) (regionRateThreshold * events.getTotalEvents(mainEvent)); boolean headerPrinted = false; int cnt = 1; for (Region r : regions) { if (r.getEventCount(events, mainEvent) > threshold) { if (!headerPrinted) { pw.printf("Hottest code regions (>%.2f%% \"%s\" events):%n", regionRateThreshold * 100, mainEvent); switch (showCounts) { case raw: pw.println(" Unaltered event counts are printed."); break; case norm: pw.println(" Event counts are normalized per @Benchmark call."); break; case percent_total: pw.println(" Event counts are percents of total event count."); break; default: throw new IllegalStateException("Unhandled enum: " + showCounts); } pw.println(); headerPrinted = true; } printDottedLine(pw, "Hottest Region " + cnt); pw.printf("%s, %s %n%n", r.desc().source(), r.desc().name()); r.printCode(pw, events); printDottedLine(pw); for (String event : evNames) { printLine(pw, events, event, r.getEventCount(events, event), context); } pw.println(""); pw.println(); cnt++; } } if (!headerPrinted) { pw.printf("WARNING: No hottest code region above the threshold (%.2f%%) for disassembly.%n", regionRateThreshold * 100); pw.println("Use \"hotThreshold\" profiler option to lower the filter threshold."); pw.println(); } int lenSource = 0; for (Region r : regions) { lenSource = Math.max(lenSource, r.desc().source().length()); } /** * 6. Print out the hottest regions */ { Multiset total = new HashMultiset<>(); Multiset other = new HashMultiset<>(); printDottedLine(pw, "Hottest Regions"); int shown = 0; for (Region r : regions) { if (shown++ < regionShowTop) { for (String event : evNames) { printLine(pw, events, event, r.getEventCount(events, event), context); } pw.printf("%" + lenSource + "s %s %n", r.desc().source(), r.desc().name()); } else { for (String event : evNames) { other.add(event, r.getEventCount(events, event)); } } for (String event : evNames) { total.add(event, r.getEventCount(events, event)); } } if (regions.size() - regionShowTop > 0) { for (String event : evNames) { printLine(pw, events, event, other.count(event), context); } pw.println("<...other " + (regions.size() - regionShowTop) + " warm regions...>"); } printDottedLine(pw); for (String event : evNames) { printLine(pw, events, event, total.count(event), context); } pw.println(""); pw.println(); } final Map> methodsByType = new HashMap<>(); final Map> methods = new HashMap<>(); for (String event : evNames) { methodsByType.put(event, new HashMultiset<>()); methods.put(event, new HashMultiset<>()); } for (Region r : regions) { for (String event : evNames) { long count = r.getEventCount(events, event); methods.get(event).add(r.desc(), count); methodsByType.get(event).add(r.desc().source(), count); } } /** * Print out hottest methods */ { printDottedLine(pw, "Hottest Methods (after inlining)"); Multiset total = new HashMultiset<>(); Multiset other = new HashMultiset<>(); int shownMethods = 0; List top = Multisets.sortedDesc(methods.get(mainEvent)); for (MethodDesc m : top) { if (shownMethods++ < regionShowTop) { for (String event : evNames) { printLine(pw, events, event, methods.get(event).count(m), context); } pw.printf("%" + lenSource + "s %s %n", m.source(), m.name()); } else { for (String event : evNames) { other.add(event, methods.get(event).count(m)); } } for (String event : evNames) { total.add(event, methods.get(event).count(m)); } } if (top.size() - regionShowTop > 0) { for (String event : evNames) { printLine(pw, events, event, other.count(event), context); } pw.println("<...other " + (top.size() - regionShowTop) + " warm methods...>"); } printDottedLine(pw); for (String event : evNames) { printLine(pw, events, event, total.count(event), context); } pw.println(""); pw.println(); } /** * Print hot methods distribution */ { printDottedLine(pw, "Distribution by Source"); for (String m : Multisets.sortedDesc(methodsByType.get(mainEvent))) { for (String event : evNames) { printLine(pw, events, event, methodsByType.get(event).count(m), context); } pw.printf("%" + lenSource + "s%n", m); } printDottedLine(pw); for (String event : evNames) { printLine(pw, events, event, methodsByType.get(event).size(), context); } pw.println(""); pw.println(); } /** * Final checks on assembly: */ { Set addrHistory = new HashSet<>(); for (Long addr : assembly.addressMap.keySet()) { if (!addrHistory.add(addr)) { pw.println("WARNING: Duplicate instruction addresses detected. This is probably due to compiler reusing\n " + "the code arena for the new generated code. We can not differentiate between methods sharing\n" + "the same addresses, and therefore the profile might be wrong. Increasing generated code\n" + "storage might help."); } } } { int sum = 0; for (Long v : events.totalCounts.values()) { sum += v; } if (sum < 1000) { pw.println("WARNING: The perf event count is suspiciously low (" + sum + "). The performance data might be"); pw.println("inaccurate or misleading. Try to do the profiling again, or tune up the sampling frequency."); pw.println("With some profilers on Mac OS X, System Integrity Protection (SIP) may prevent profiling."); pw.println("In such case, temporarily disabling SIP with 'csrutil disable' might help."); } } /** * Print perf output, if needed: */ if (savePerfOutput) { String target = (savePerfOutputToFile == null) ? savePerfOutputTo + "/" + br.getParams().id() + ".perf" : savePerfOutputToFile; try { FileUtils.copy(perfParsedData.getAbsolutePath(), target); pw.println("Perf output saved to " + target); } catch (IOException e) { pw.println("Unable to save perf output to " + target); } } /** * Print binary perf output, if needed: */ if (savePerfBin) { String target = (savePerfBinFile == null) ? savePerfBinTo + "/" + br.getParams().id() + perfBinaryExtension() : savePerfBinFile; try { FileUtils.copy(perfBinData.getAbsolutePath(), target); pw.println("Perf binary output saved to " + target); } catch (IOException e) { pw.println("Unable to save perf binary output to " + target); } } /** * Print annotated assembly, if needed: */ if (saveLog) { String target = (saveLogToFile == null) ? saveLogTo + "/" + br.getParams().id() + ".log" : saveLogToFile; try (FileOutputStream asm = new FileOutputStream(target); PrintWriter pwAsm = new PrintWriter(asm)) { for (ASMLine line : assembly.lines) { for (String event : evNames) { long count = (line.addr != null) ? events.get(event).count(line.addr) : 0; printLine(pwAsm, events, event, count, context); } pwAsm.println(line.code); } pw.println("Perf-annotated Hotspot log is saved to " + target); } catch (IOException e) { pw.println("Unable to save Hotspot log to " + target); } } pw.flush(); pw.close(); return new TextResult(sw.toString(), "asm"); } private static void printLine(PrintWriter pw, PerfEvents events, String event, long count, PrintContext context) { if (count > 0) { switch (context.mode) { case raw: pw.printf("%" + context.formatWidth + "d ", count); break; case norm: pw.printf("%" + context.formatWidth + "." + context.formatMinor + "f ", 100.0 * count / context.ops); break; case percent_total: pw.printf("%" + context.formatWidth + "." + context.formatMinor + "f%% ", 100.0 * count / events.getTotalEvents(event)); break; default: throw new IllegalStateException("Unhandled enum: " + context.mode); } } else { pw.printf("%" + context.formatWidth + "s ", ""); } } private void printDottedLine(PrintWriter pw) { printDottedLine(pw, null); } private void printDottedLine(PrintWriter pw, String header) { final int HEADER_WIDTH = 100; pw.print("...."); if (header != null) { header = "[" + header + "]"; pw.print(header); } else { header = ""; } for (int c = 0; c < HEADER_WIDTH - 4 - header.length(); c++) { pw.print("."); } pw.println(); } private List makeRegions(Assembly asms, PerfEvents events, PrintContext context) { List strippedEvents = stripEventNames(requestedEventNames); List regions = new ArrayList<>(); SortedSet allAddrs = events.getAllAddresses(); for (Interval intv : figureHotIntervals(allAddrs, asms)) { SortedSet eventfulAddrs = allAddrs.subSet(intv.src, intv.dst + 1); List regionLines = asms.getLines(intv.src, intv.dst, printMargin); if (!regionLines.isEmpty()) { // has some associated assembly // TODO: Should scan and split regions for multiple descs? MethodDesc desc = asms.getMethod(intv.src); if (desc == null) { desc = MethodDesc.unknown(); } regions.add(new GeneratedRegion(strippedEvents, asms, desc, intv.src, intv.dst, regionLines, eventfulAddrs, regionTooBigThreshold, drawIntraJumps, drawInterJumps, context)); } else { // has no assembly, should be a native region // TODO: Should scan and split regions for multiple descs? MethodDesc desc = events.getMethod(intv.src); if (desc == null) { desc = MethodDesc.unknown(); } regions.add(new NativeRegion(desc, intv.src, intv.dst, eventfulAddrs)); } } return regions; } private List figureHotIntervals(SortedSet addrs, Assembly asms) { if (addrs.isEmpty()) { return Collections.emptyList(); } List intervals = new ArrayList<>(); long begAddr = addrs.first(); long lastAddr = addrs.first(); for (long addr : addrs) { if (addr - lastAddr > mergeMargin) { addInterval(intervals, begAddr, lastAddr, asms); begAddr = addr; } lastAddr = addr; } if (begAddr != lastAddr) { addInterval(intervals, begAddr, lastAddr, asms); } return intervals; } private void addInterval(List intervals, long begAddr, long lastAddr, Assembly asms) { if (!mergeMethods || intervals.isEmpty()) { intervals.add(new Interval(begAddr, lastAddr)); } else { Interval prev = intervals.get(intervals.size() - 1); MethodDesc prevMethod = asms.getMethod(prev.src); MethodDesc method = asms.getMethod(begAddr); if (prevMethod == null || !prevMethod.equals(method)) { intervals.add(new Interval(begAddr, lastAddr)); } else { intervals.set(intervals.size() - 1, new Interval(prev.src, lastAddr)); } } } private Collection> splitAssembly(File stdOut) { try (FileReader in = new FileReader(stdOut); BufferedReader br = new BufferedReader(in)) { Multimap writerToLines = new HashMultimap<>(); long writerId = -1L; final Pattern writerThreadPattern = Pattern.compile("(.*)(.*)"); String line; while ((line = br.readLine()) != null) { // Parse the writer threads IDs: // if (line.contains(" final Pattern nmethodPattern = Pattern.compile("(.*?)(.*?)"); for (Collection cs : splitAssembly(stdOut)) { String prevLine = ""; for (String line : cs) { String trim = line.trim(); if (trim.isEmpty()) { // Filter out empty lines for denser output, more efficient matching, // and trustworthy prevLine. continue; } List addrs = parseAddresses(trim, true, true); ASMLine asmLine = new ASMLine(line); // Handle the most frequent case first. if (addrs.size() > 0) { long startAddr = addrs.get(0); int idx = lines.size(); addressMap.put(startAddr, idx); asmLine = new ASMLine(startAddr, line); if (addrs.size() > 1 && (drawInterJumps || drawIntraJumps)) { for (int c = 1; c < addrs.size(); c++) { long targetAddr = addrs.get(c); intervals.add(new Interval(startAddr, targetAddr)); } } } if (prevLine.contains("--------") || line.contains("StubRoutines::")) { Matcher matcher = interpreterStubPattern.matcher(line); if (matcher.matches()) { String name = matcher.group(1); List stubAddrs = parseAddresses(trim, true, false); if (stubAddrs.size() == 2) { long startAddr = stubAddrs.get(0); long endAddr = stubAddrs.get(1); if (line.contains("StubRoutines::")) { stubs.add(MethodDesc.runtimeStub(name), startAddr, endAddr); } else { stubs.add(MethodDesc.interpreter(name), startAddr, endAddr); } } } } if (line.contains(" map = new HashMap<>(); for (String kv : kvs) { String[] pair = kv.split("="); // Guard against "key=''" if (pair.length == 2) { map.put(pair[0], pair[1]); } else { map.put(pair[0], null); } } // Record the starting address for the method List entryAddrs = parseAddresses(map.get("entry"), true, true); long addr = entryAddrs.get(0); MethodDesc desc = MethodDesc.javaMethod( map.get("method"), map.get("compiler"), map.get("level"), methodVersions.incrementAndGet(map.get("method")), map.get("compile_id")); javaMethods.add( desc, addr, addr + Long.parseLong(map.get("size")) ); } } lines.add(asmLine); prevLine = line; } } // Important to get the order right: all Java methods take precedence over interpreter/runtime stubs. IntervalMap methodMap = new IntervalMap<>(); methodMap.merge(stubs); methodMap.merge(javaMethods); return new Assembly(lines, addressMap, methodMap, intervals); } private static final List EMPTY_LIST_LONGS = Collections.unmodifiableList(new ArrayList<>()); private static final Pattern ADDR_LINE_SPLIT = Pattern.compile("\\W+"); static List parseAddresses(String line, boolean alreadyTrimmed, boolean shouldStartWithAddr) { if (!alreadyTrimmed) { line = line.trim(); } List addrs = new ArrayList<>(); String[] elements = ADDR_LINE_SPLIT.split(line); for (int i = 0; i < elements.length; i++) { String el = elements[i]; String str = null; if (el.startsWith("0x")) { // AT&T address format str = el.replace("0x", "").replace(":", ""); } else if (el.endsWith("h")) { // Intel address format str = el.replace("h", ""); } else if (shouldStartWithAddr && (i == 0)) { // First element is not address, the line is wrong return EMPTY_LIST_LONGS; } if (str != null) { try { addrs.add(Long.parseLong(str, 16)); } catch (NumberFormatException nfe) { // It looked like an address, but was not. } } } return Collections.unmodifiableList(addrs); } protected static class PerfEvents { final Map> events; final IntervalMap methods; final Map totalCounts; PerfEvents(Collection tracedEvents, Map> events, IntervalMap methods) { this.events = events; this.methods = methods; this.totalCounts = new HashMap<>(); for (String event : tracedEvents) { totalCounts.put(event, events.get(event).size()); } } public boolean isEmpty() { return events.isEmpty(); } public Multiset get(String event) { return events.get(event); } public SortedSet getAllAddresses() { SortedSet addrs = new TreeSet<>(); for (Multiset e : events.values()) { addrs.addAll(e.keys()); } return addrs; } public Long getTotalEvents(String event) { return totalCounts.get(event); } public MethodDesc getMethod(long addr) { return methods.get(addr); } } static class Assembly { final List lines; final SortedMap addressMap; final IntervalMap methodMap; final Set intervals; public Assembly(List lines, SortedMap addressMap, IntervalMap methodMap, Set intervals) { this.lines = lines; this.addressMap = addressMap; this.methodMap = methodMap; this.intervals = intervals; } public int size() { // We only care about the address lines. return addressMap.size(); } private boolean isSameMethod(MethodDesc method, int idx) { ASMLine line = lines.get(idx); Long addr = line != null ? line.addr : null; MethodDesc m = addr != null ? getMethod(addr) : null; // If we cannot find a method for the line, assume it "equals" return (m == null) || Objects.equals(m, method); } private int adjustWindowForward(MethodDesc method, int beginIdx, int window) { for (; beginIdx > 0 && window > 0; beginIdx--, window--) { if (!isSameMethod(method, beginIdx - 1)) { return beginIdx; } } return beginIdx; } private int adjustWindowBackward(MethodDesc method, int endIdx, int window) { int size = lines.size(); for (; endIdx < size && window > 0; endIdx++, window--) { if (!isSameMethod(method, endIdx)) { return endIdx; } } return endIdx; } public List getLines(long begin, long end, int window) { SortedMap tailMap = addressMap.tailMap(begin); Long beginAddr; Integer beginIdx; if (!tailMap.isEmpty()) { beginAddr = tailMap.firstKey(); beginIdx = addressMap.get(beginAddr); } else { return Collections.emptyList(); } SortedMap headMap = addressMap.headMap(end); Long endAddr; Integer endIdx; if (!headMap.isEmpty()) { endAddr = headMap.lastKey(); endIdx = addressMap.get(endAddr); } else { return Collections.emptyList(); } MethodDesc method = getMethod(begin); beginIdx = adjustWindowForward(method, beginIdx, window); endIdx = adjustWindowBackward(method, endIdx, 2 + window); // Compensate for minute discrepancies if (beginIdx < endIdx) { return lines.subList(beginIdx, endIdx); } else { return Collections.emptyList(); } } public MethodDesc getMethod(long addr) { return methodMap.get(addr); } } static class ASMLine { final Long addr; final String code; ASMLine(String code) { this(null, code); } ASMLine(Long addr, String code) { this.addr = addr; this.code = code; } } static class Region { final MethodDesc method; final long begin; final long end; final Set eventfulAddrs; final Map eventCountCache; Region(MethodDesc method, long begin, long end, Set eventfulAddrs) { this.method = method; this.begin = begin; this.end = end; this.eventfulAddrs = eventfulAddrs; this.eventCountCache = new HashMap<>(); } long getEventCount(PerfEvents events, String event) { if (!eventCountCache.containsKey(event)) { Multiset evs = events.get(event); long count = 0; for (Long addr : eventfulAddrs) { count += evs.count(addr); } eventCountCache.put(event, count); } return eventCountCache.get(event); } public void printCode(PrintWriter pw, PerfEvents events) { pw.println(""); } public MethodDesc desc() { return method; } } static class GeneratedRegion extends Region { final Collection tracedEvents; final Assembly asms; final Collection code; final int threshold; final boolean drawIntraJumps; final boolean drawInterJumps; final PrintContext context; GeneratedRegion(Collection tracedEvents, Assembly asms, MethodDesc desc, long begin, long end, Collection code, Set eventfulAddrs, int threshold, boolean drawIntraJumps, boolean drawInterJumps, PrintContext context) { super(desc, begin, end, eventfulAddrs); this.tracedEvents = tracedEvents; this.asms = asms; this.code = code; this.threshold = threshold; this.drawIntraJumps = drawIntraJumps; this.drawInterJumps = drawInterJumps; this.context = context; } @Override public void printCode(PrintWriter pw, PerfEvents events) { if (code.size() > threshold) { pw.printf(" %n", code.size(), threshold); } else { long beginLine = begin; long endLine = end; for (ASMLine line : code) { Long addr = line.addr; if (addr != null) { beginLine = Math.min(beginLine, addr); endLine = Math.max(endLine, addr); } } Set interIvs = new TreeSet<>(); Set intraIvs = new TreeSet<>(); for (Interval it : asms.intervals) { boolean srcInline = (beginLine < it.src && it.src < endLine); boolean dstInline = (beginLine < it.dst && it.dst < endLine); if (srcInline && dstInline) { if (drawInterJumps) { interIvs.add(it); } } else if (srcInline || dstInline) { if (drawIntraJumps) { intraIvs.add(it); } } } long prevAddr = 0; for (ASMLine line : code) { for (String event : tracedEvents) { long count = (line.addr != null) ? events.get(event).count(line.addr) : 0; printLine(pw, events, event, count, context); } long addr; long evAddr; if (line.addr == null) { addr = prevAddr; evAddr = -1; } else { addr = line.addr; evAddr = addr; prevAddr = addr; } for (Interval it : intraIvs) { printInterval(pw, it, addr, evAddr, false); } for (Interval it : interIvs) { printInterval(pw, it, addr, evAddr, true); } pw.println(line.code); } } } private void printInterval(PrintWriter pw, Interval it, long addr, long evAddr, boolean inline) { if (it.src < it.dst) { // flows downwards if (it.src == evAddr) { pw.print("\u256d"); } else if (it.dst == evAddr) { pw.print("\u2198"); } else if ((it.src <= addr) && (addr < it.dst)) { if (inline) { pw.print("\u2502"); } else { pw.print("\u2575"); } } else { pw.print(" "); } } else { // flows upwards if (it.src == evAddr) { pw.print("\u2570"); } else if (it.dst == evAddr) { pw.print("\u2197"); } else if ((it.dst <= addr) && (addr < it.src)) { if (inline) { pw.print("\u2502"); } else { pw.print("\u2575"); } } else { pw.print(" "); } } } } static class NativeRegion extends Region { NativeRegion(MethodDesc desc, long begin, long end, Set eventfulAddrs) { super(desc, begin, end, eventfulAddrs); } @Override public void printCode(PrintWriter pw, PerfEvents events) { pw.println(" "); } } static class UnknownRegion extends Region { UnknownRegion() { super(MethodDesc.unknown(), 0L, 0L, Collections.singleton(0L)); } @Override public void printCode(PrintWriter pw, PerfEvents events) { pw.println(" "); } } static class MethodDesc { private final String name; private final String source; protected MethodDesc(String name, String source) { this.name = name; this.source = source; } public static MethodDesc unresolved() { return new MethodDesc("", ""); } public static MethodDesc unknown() { return new MethodDesc("", ""); } public static MethodDesc kernel() { return new MethodDesc("", "kernel"); } public static MethodDesc interpreter(String name) { return new MethodDesc(name, "interpreter"); } public static MethodDesc runtimeStub(String name) { return new MethodDesc(name, "runtime stub"); } public static MethodDesc javaMethod(String name, String compiler, String level, int ver, String compileId) { String methodName = name.replace("/", ".").replaceFirst(" ", "::").split(" ")[0]; return new MethodDesc( methodName + ", version " + ver + ", compile id " + compileId, (compiler != null ? compiler : "Unknown") + (level != null ? ", level " + level : "") ); } public static MethodDesc nativeMethod(String symbol, String lib) { return new MethodDesc(symbol, lib); } public String name() { return name; } public String source() { return source; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MethodDesc that = (MethodDesc) o; if (!name.equals(that.name)) return false; return source.equals(that.source); } @Override public int hashCode() { int result = name.hashCode(); result = 31 * result + source.hashCode(); return result; } @Override public String toString() { return "MethodDesc{" + "name='" + name + '\'' + ", source='" + source + '\'' + '}'; } } private static class PrintContext { private final ShowCounts mode; private final long ops; private final int formatWidth; private final int formatMinor; public PrintContext(ShowCounts mode, long ops, int formatWidth, int formatMinor) { this.mode = mode; this.ops = ops; this.formatWidth = formatWidth; this.formatMinor = formatMinor; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java000066400000000000000000000604701446271450100264570ustar00rootroot00000000000000/* * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.TextResult; import org.openjdk.jmh.runner.IterationType; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.*; /** * A profiler based on async-profiler. * * @author Jason Zaugg */ public final class AsyncProfiler implements ExternalProfiler, InternalProfiler { private final JavaApi instance; private final boolean verbose; private final Direction direction; private final String profilerConfig; private final List output; private final String outputFilePrefix; private final File outDir; private File trialOutDir; private final int traces; private final int flat; private boolean isVersion1x; private boolean warmupStarted; private boolean measurementStarted; private int measurementIterationCount; private final LinkedHashSet generated = new LinkedHashSet<>(); public AsyncProfiler(String initLine) throws ProfilerException { OptionParser parser = new OptionParser(); parser.formatHelpWith(new ProfilerOptionFormatter("async")); OptionSpec optOutput = parser.accepts("output", "Output format(s). Supported: " + EnumSet.allOf(OutputType.class) + ".") .withRequiredArg().ofType(OutputType.class).withValuesSeparatedBy(",").describedAs("format+").defaultsTo(OutputType.text); OptionSpec optDirection = parser.accepts("direction", "Direction(s) of flame graph. Supported: " + EnumSet.allOf(Direction.class) + ".") .withRequiredArg().ofType(Direction.class).describedAs("direction").defaultsTo(Direction.both); OptionSpec optLibPath = parser.accepts("libPath", "Location of asyncProfiler library. If not specified, System.loadLibrary will be used " + "and the library must be made available to the forked JVM in an entry of -Djava.library.path, " + "LD_LIBRARY_PATH (Linux), or DYLD_LIBRARY_PATH (Mac OS).") .withRequiredArg().ofType(String.class).describedAs("path"); OptionSpec optEvent = parser.accepts("event", "Event to sample: cpu, alloc, lock, wall, itimer; com.foo.Bar.methodName; any event from `perf list` e.g. cache-misses") .withRequiredArg().ofType(String.class).describedAs("event").defaultsTo("cpu"); String secondaryEventOk = "May be captured as a secondary event under output=jfr."; OptionSpec optAlloc = parser.accepts("alloc", "Enable allocation profiling. Optional argument (e.g. =512k) reduces sampling from the default of one-sample-per-TLAB. " + secondaryEventOk) .withOptionalArg().ofType(String.class).describedAs("sample bytes"); OptionSpec optLock = parser.accepts("lock", "Enable lock profiling. Optional argument (e.g. =1ms) limits capture based on lock duration. " + secondaryEventOk) .withOptionalArg().ofType(String.class).describedAs("duration"); OptionSpec optDir = parser.accepts("dir", "Output directory.") .withRequiredArg().ofType(String.class).describedAs("dir"); OptionSpec optInterval = parser.accepts("interval", "Profiling interval.") .withRequiredArg().ofType(Long.class).describedAs("ns"); OptionSpec optJstackDepth = parser.accepts("jstackdepth", "Maximum Java stack depth.") .withRequiredArg().ofType(Integer.class).describedAs("frames"); OptionSpec optFrameBuf = parser.accepts("framebuf", "Size of profiler framebuffer.") .withRequiredArg().ofType(Long.class).describedAs("bytes"); OptionSpec optFilter = parser.accepts("filter", "Enable thread filtering during collection. Useful for wall clock profiling, " + "but only if the workload registers the relevant threads programatically " + "via `AsyncProfiler.JavaApi.getInstance().filterThread(thread, enabled)`.") .withRequiredArg().ofType(Boolean.class).defaultsTo(false).describedAs("boolean"); OptionSpec optThreads = parser.accepts("threads", "Profile threads separately.") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optSimple = parser.accepts("simple", "Simple class names instead of FQN.") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optSig = parser.accepts("sig", "Print method signatures.") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optAnn = parser.accepts("ann", "Annotate Java method names.") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optInclude = parser.accepts("include", "Output only stack traces containing the specified pattern.") .withRequiredArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("regexp+"); OptionSpec optExclude = parser.accepts("exclude", "Exclude stack traces with the specified pattern.") .withRequiredArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("regexp+"); OptionSpec optRawCommand = parser.accepts("rawCommand", "Command to pass directly to async-profiler. Use to access new features of JMH " + "profiler that are not yet supported in this option parser.") .withRequiredArg().ofType(String.class).describedAs("command"); OptionSpec optTitle = parser.accepts("title", "SVG title.") .withRequiredArg().ofType(String.class).describedAs("string"); OptionSpec optWidth = parser.accepts("width", "SVG width.") .withRequiredArg().ofType(Long.class).describedAs("pixels"); OptionSpec optMinWidth = parser.accepts("minwidth", "Skip frames smaller than px") .withRequiredArg().ofType(Long.class).describedAs("pixels"); OptionSpec optAllKernel = parser.accepts("allkernel", "Only include kernel-mode events.") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optAllUser = parser.accepts("alluser", "Only include user-mode events.") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optCStack = parser.accepts("cstack", "How to traverse C stack: Supported: " + EnumSet.allOf(CStackMode.class) + ".") .withRequiredArg().ofType(CStackMode.class).describedAs("mode"); OptionSpec optVerbose = parser.accepts("verbose", "Output the sequence of commands.") .withRequiredArg().ofType(Boolean.class).defaultsTo(false).describedAs("bool"); OptionSpec optTraces = parser.accepts("traces", "Number of top traces to include in the default output.") .withRequiredArg().ofType(Integer.class).defaultsTo(200).describedAs("int"); OptionSpec optFlat = parser.accepts("flat", "Number of top flat profiles to include in the default output.") .withRequiredArg().ofType(Integer.class).defaultsTo(200).describedAs("int"); OptionSet set = ProfilerUtils.parseInitLine(initLine, parser); try { ProfilerOptionsBuilder builder = new ProfilerOptionsBuilder(set); if (!set.has(optDir)) { outDir = new File(System.getProperty("user.dir")); } else { outDir = new File(set.valueOf(optDir)); } builder.appendIfExists(optInterval); builder.appendIfExists(optJstackDepth); builder.appendIfTrue(optThreads); builder.appendIfTrue(optSimple); builder.appendIfTrue(optSig); builder.appendIfTrue(optAnn); builder.appendIfExists(optFrameBuf); if (optFilter.value(set)) { builder.appendRaw("filter"); } builder.appendMulti(optInclude); builder.appendMulti(optExclude); builder.appendIfExists(optTitle); builder.appendIfExists(optWidth); builder.appendIfExists(optMinWidth); builder.appendIfTrue(optAllKernel); builder.appendIfTrue(optAllUser); builder.appendIfExists(optCStack); if (set.has(optRawCommand)) { builder.appendRaw(optRawCommand.value(set)); } traces = optTraces.value(set); flat = optFlat.value(set); try { if (set.has(optLibPath)) { instance = JavaApi.getInstance(optLibPath.value(set)); } else { instance = JavaApi.getInstance(); } } catch (UnsatisfiedLinkError e) { throw new ProfilerException("Unable to load async-profiler. Ensure asyncProfiler library " + "is on LD_LIBRARY_PATH (Linux), DYLD_LIBRARY_PATH (Mac OS), or -Djava.library.path. " + "Alternatively, point to explicit library location with -prof async:libPath=.", e); } verbose = optVerbose.value(set); try { String version = instance.execute("version"); if (verbose) { System.out.println("[async-profiler] version=" + version); } isVersion1x = version.startsWith("1."); } catch (IOException e) { throw new ProfilerException(e); } direction = optDirection.value(set); output = optOutput.values(set); // Secondary events are those that may be collected simultaneously with a primary event in a JFR profile. // To be used as such, we require they are specifed with the lock and alloc option, rather than event=lock, // event=alloc. Set secondaryEvents = new HashSet<>(); if (set.has(optAlloc)) { secondaryEvents.add("alloc"); builder.append(optAlloc); } if (set.has(optLock)) { secondaryEvents.add("lock"); builder.append(optLock); } if (set.has(optEvent)) { String evName = set.valueOf(optEvent); if (evName.contains(",")) { throw new ProfilerException("Event name should not contain commas: " + evName); } outputFilePrefix = evName; builder.append(optEvent); } else { if (secondaryEvents.isEmpty()) { // Default to the cpu event if no events at all are selected. builder.appendRaw("event=cpu"); outputFilePrefix = "cpu"; } else if (secondaryEvents.size() == 1) { // No primary event, one secondary -- promote it to the primary event. This means any output // format is allowed and the event name will be included in the output file name. outputFilePrefix = secondaryEvents.iterator().next(); secondaryEvents.clear(); } else { outputFilePrefix = "profile"; } } if (!secondaryEvents.isEmpty()) { if (isVersion1x) { throw new ProfilerException("Secondary event capture not supported on async-profiler 1.x"); } if (output.size() > 1 || output.get(0) != OutputType.jfr) { throw new ProfilerException("Secondary event capture is only supported with output=" + OutputType.jfr.name()); } } profilerConfig = builder.profilerOptions(); } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } } @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { if (trialOutDir == null) { createTrialOutDir(benchmarkParams); } if (iterationParams.getType() == IterationType.WARMUP) { if (!warmupStarted) { // Collect profiles during warmup to warmup the profiler itself. start(); warmupStarted = true; } } if (iterationParams.getType() == IterationType.MEASUREMENT) { if (!measurementStarted) { if (warmupStarted) { // Discard samples collected during warmup... execute("stop"); } // ...and start collecting again. start(); measurementStarted = true; } } } private void start() { if (output.contains(OutputType.jfr)) { execute("start," + profilerConfig + ",file=" + outputFile("jfr-%s.jfr").getAbsolutePath()); } else { execute("start," + profilerConfig); } } @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult iterationResult) { if (iterationParams.getType() == IterationType.MEASUREMENT) { measurementIterationCount += 1; if (measurementIterationCount == iterationParams.getCount()) { return Collections.singletonList(stopAndDump()); } } return Collections.emptyList(); } private void createTrialOutDir(BenchmarkParams benchmarkParams) { if (trialOutDir == null) { // async-profiler expands %p to PID and %t to timestamp, make sure we don't // include % in the file name. String fileName = benchmarkParams.id().replace("%", "_"); trialOutDir = new File(outDir, fileName); trialOutDir.mkdirs(); } } private TextResult stopAndDump() { execute("stop"); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); for (OutputType outputType : output) { switch (outputType) { case text: File out = outputFile("summary-%s.txt"); if (isVersion1x) { dump(out, "summary,flat=" + flat + ",traces=" + traces); } else { dump(out, "flat=" + flat + ",traces=" + traces); } try { for (String line : FileUtils.readAllLines(out)) { pw.println(line); } } catch (IOException e) { throw new RuntimeException(e); } break; case collapsed: dump(outputFile("collapsed-%s.csv"), "collapsed"); break; case flamegraph: // The last SVG-enabled version is 1.x String ext = isVersion1x ? "svg" : "html"; if (direction == Direction.both || direction == Direction.forward) { dump(outputFile("flame-%s-forward." + ext), "flamegraph"); } if (direction == Direction.both || direction == Direction.reverse) { dump(outputFile("flame-%s-reverse." + ext), "flamegraph,reverse"); } break; case tree: dump(outputFile("tree-%s.html"), "tree"); break; case jfr: // JFR is already dumped into file by async-profiler. break; } } pw.println("Async profiler results:"); for (File file : generated) { pw.print(" "); pw.println(file.getPath()); } pw.flush(); pw.close(); return new TextResult(sw.toString(), "async"); } private void dump(File target, String command) { execute(command + "," + profilerConfig + ",file=" + target.getAbsolutePath()); } private File outputFile(String fileNameFormat) { File output = new File(trialOutDir, String.format(fileNameFormat, outputFilePrefix)); generated.add(output); return output; } private String execute(String command) { if (verbose) { System.out.println("[async-profiler] " + command); } try { return instance.execute(command); } catch (IOException e) { throw new RuntimeException(e); } } public enum CStackMode { fp, lbr, no } public enum OutputType { text, collapsed, flamegraph, tree, jfr } public enum Direction { forward, reverse, both, } private static class ProfilerOptionsBuilder { private final OptionSet optionSet; private final StringBuilder profilerOptions; ProfilerOptionsBuilder(OptionSet optionSet) { this.optionSet = optionSet; this.profilerOptions = new StringBuilder(); } void appendIfExists(OptionSpec option) { if (optionSet.has(option)) { append(option); } } void append(OptionSpec option) { assert (option.options().size() == 1); String optionName = option.options().iterator().next(); separate(); profilerOptions.append(optionName); T arg = optionSet.valueOf(option); if (arg != null) { profilerOptions.append('=').append(arg); } } void appendRaw(String command) { separate(); profilerOptions.append(command); } private void separate() { if (profilerOptions.length() > 0) { profilerOptions.append(','); } } void appendIfTrue(OptionSpec option) { if (optionSet.has(option) && optionSet.valueOf(option)) { append(option); } } void appendMulti(OptionSpec option) { if (optionSet.has(option)) { assert (option.options().size() == 1); String optionName = option.options().iterator().next(); for (T value : optionSet.valuesOf(option)) { separate(); profilerOptions.append(optionName).append('=').append(value.toString()); } } } public String profilerOptions() { return profilerOptions.toString(); } } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public Collection addJVMOptions(BenchmarkParams params) { List args = new ArrayList<>(); args.add("-XX:+UnlockDiagnosticVMOptions"); // Recommended option for async-profiler, enable automatically. args.add("-XX:+DebugNonSafepoints"); return args; } @Override public void beforeTrial(BenchmarkParams benchmarkParams) { } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { return Collections.emptyList(); } @Override public boolean allowPrintOut() { return true; } @Override public boolean allowPrintErr() { return true; } @Override public String getDescription() { return "async-profiler profiler provider."; } // Made public so that power-users could can call filterThread from within the workload // to limit collection to a set of threads. This is useful for wall-clock profiling. // Adding support in JMH to pass the threads to profilers seems like an invasive change for // this niche use case. public static final class JavaApi { private static EnumSet ignoredThreadStates = EnumSet.of(Thread.State.NEW, Thread.State.TERMINATED); private static JavaApi INSTANCE; public static JavaApi getInstance(String libraryFileName) { if (INSTANCE == null) { synchronized (AsyncProfiler.class) { INSTANCE = new JavaApi(libraryFileName); } } return INSTANCE; } public static JavaApi getInstance() { if (INSTANCE == null) { synchronized (AsyncProfiler.class) { INSTANCE = new JavaApi(); } } return INSTANCE; } private JavaApi(String libraryFileName) { System.load(libraryFileName); } private JavaApi() { System.loadLibrary("asyncProfiler"); } public String execute(String command) throws IOException { return execute0(command); } /** * Enable or disable profile collection for threads. * * @param thread The thread to enable or disable. * null indicates the current thread. * @param enable Whether to enable or disable. */ public void filterThread(Thread thread, boolean enable) { if (thread == null) { filterThread0(null, enable); } else { synchronized (thread) { Thread.State state = thread.getState(); if (!ignoredThreadStates.contains(state)) { filterThread0(thread, enable); } } } } // Loading async-profiler will automatically bind these native methods to the profiler implementation. private native void start0(String event, long interval, boolean reset) throws IllegalStateException; private native void stop0() throws IllegalStateException; private native String execute0(String command) throws IllegalArgumentException, IOException; private native long getSamples(); private native void filterThread0(Thread thread, boolean enable); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java000066400000000000000000000074721446271450100276410ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; import java.lang.management.ClassLoadingMXBean; import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.TimeUnit; public class ClassloaderProfiler implements InternalProfiler { private long loadedClasses; private long unloadedClasses; private long beforeTime; private long afterTime; @Override public String getDescription() { return "Classloader profiling via standard MBeans"; } @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean(); this.beforeTime = System.nanoTime(); try { loadedClasses = cl.getTotalLoadedClassCount(); } catch (UnsupportedOperationException e) { // do nothing } try { unloadedClasses = cl.getUnloadedClassCount(); } catch (UnsupportedOperationException e) { // do nothing } } @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { afterTime = System.nanoTime(); List results = new ArrayList<>(); ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean(); long allOps = result.getMetadata().getAllOps(); double time = 1.0 * TimeUnit.SECONDS.toNanos(1) / (afterTime - beforeTime); try { long loadedClassCount = cl.getTotalLoadedClassCount(); long loaded = loadedClassCount - loadedClasses; results.add(new ScalarResult("class.load", loaded / time, "classes/sec", AggregationPolicy.AVG)); results.add(new ScalarResult("class.load.norm", 1.0 * loaded / allOps, "classes/op", AggregationPolicy.AVG)); } catch (UnsupportedOperationException e) { // do nothing } try { long unloadedClassCount = cl.getUnloadedClassCount(); long unloaded = unloadedClassCount - unloadedClasses; results.add(new ScalarResult("class.unload", unloaded / time, "classes/sec", AggregationPolicy.AVG)); results.add(new ScalarResult("class.unload.norm", 1.0 * unloaded / allOps, "classes/op", AggregationPolicy.AVG)); } catch (UnsupportedOperationException e) { // do nothing } return results; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/CompilerProfiler.java000066400000000000000000000060701446271450100271500ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; import java.lang.management.CompilationMXBean; import java.lang.management.ManagementFactory; import java.util.Arrays; import java.util.Collection; import java.util.Collections; public class CompilerProfiler implements InternalProfiler { private long startCompTime; @Override public String getDescription() { return "JIT compiler profiling via standard MBeans"; } public CompilerProfiler() throws ProfilerException { CompilationMXBean comp = ManagementFactory.getCompilationMXBean(); if (!comp.isCompilationTimeMonitoringSupported()) { throw new ProfilerException("The MXBean is available, but compilation time monitoring is disabled."); } } @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { CompilationMXBean comp = ManagementFactory.getCompilationMXBean(); try { startCompTime = comp.getTotalCompilationTime(); } catch (UnsupportedOperationException e) { // do nothing } } @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { CompilationMXBean comp = ManagementFactory.getCompilationMXBean(); try { long curTime = comp.getTotalCompilationTime(); return Arrays.asList( new ScalarResult("compiler.time.profiled", curTime - startCompTime, "ms", AggregationPolicy.SUM), new ScalarResult("compiler.time.total", curTime, "ms", AggregationPolicy.MAX) ); } catch (UnsupportedOperationException e) { return Collections.emptyList(); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java000066400000000000000000000214251446271450100272020ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.util.*; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.TreeMap; import java.util.concurrent.TimeUnit; /** * Mac OS X perfasm profiler based on DTrace "profile-n" provider which samples program counter by timer interrupt. * Due to DTrace limitations on Mac OS X target JVM cannot be run directly under DTrace control, so DTrace is run separately, * all processes are sampled and irrelevant samples are filtered out in {@link #readEvents(double, double)} stage. * Super user privileges are required in order to run DTrace. *

* If you see a lot of "[unknown]" regions in profile then you are probably hitting kernel code, kernel sampling is not yet supported. * * @author Tolstopyatov Vsevolod * @since 18/10/2017 */ public class DTraceAsmProfiler extends AbstractPerfAsmProfiler { private final long sampleFrequency; private volatile String pid; private volatile Process dtraceProcess; private OptionSpec optFrequency; public DTraceAsmProfiler(String initLine) throws ProfilerException { super(initLine, "sampled_pc"); // Check DTrace availability Collection messages = Utils.tryWith("sudo", "-n", "dtrace", "-V"); if (!messages.isEmpty()) { throw new ProfilerException(messages.toString()); } try { sampleFrequency = set.valueOf(optFrequency); } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } } @Override public void beforeTrial(BenchmarkParams params) { super.beforeTrial(params); } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { if (pid == 0) { throw new IllegalStateException("DTrace needs the forked VM PID, but it is not initialized"); } // We cannot use Process.destroy, because it closes the streams right away. // Instead, deliver TERM by hand and wait for process to gracefully terminate. long dtracePid = Utils.getPid(dtraceProcess); if (dtracePid == 0) { throw new IllegalStateException("Cannot determine dtrace process PID"); } Collection messages = Utils.tryWith("sudo", "-n", "kill", "-TERM", Long.toString(dtracePid)); if (!messages.isEmpty()) { throw new IllegalStateException(messages.toString()); } // Wait for dtrace to finish. try { int errcode = dtraceProcess.waitFor(); if (errcode != 0) { throw new IllegalStateException("Non-zero error code from dtrace: " + errcode); } } catch (InterruptedException e) { throw new IllegalStateException("Interrupted while waiting for profiler to stop"); } this.pid = String.valueOf(pid); return super.afterTrial(br, pid, stdOut, stdErr); } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { dtraceProcess = Utils.runAsync("sudo", "-n", "dtrace", "-n", "profile-" + sampleFrequency + " /arg1/ { printf(\"%d 0x%lx %d\", pid, arg1, timestamp); ufunc(arg1)}", "-o", perfBinData.getAbsolutePath()); return Collections.emptyList(); } @Override public String getDescription() { return "DTrace profile provider + PrintAssembly Profiler"; } @Override protected void addMyOptions(OptionParser parser) { optFrequency = parser.accepts("frequency", "Sampling frequency. This is synonymous to profile-#") .withRequiredArg().ofType(Long.class).describedAs("freq").defaultsTo(1001L); } @Override protected void parseEvents() { // Do nothing because DTrace writes text output anyway } @Override protected PerfEvents readEvents(double skipMs, double lenMs) { long start = (long) skipMs; long end = (long) (skipMs + lenMs); try (FileReader fr = new FileReader(perfBinData.file()); BufferedReader reader = new BufferedReader(fr)) { Deduplicator dedup = new Deduplicator<>(); Multimap methods = new HashMultimap<>(); Multiset events = new TreeMultiset<>(); long dtraceTimestampBase = 0L; String line; while ((line = reader.readLine()) != null) { // Filter out DTrace misc if (!line.contains(":profile")) { continue; } line = line.trim(); line = line.substring(line.indexOf(":profile")); String[] splits = line.split(" ", 5); if (splits.length < 2) { // Suspect completely corrupted line, skip continue; } String sampledPid = splits[1]; if (!sampledPid.equals(pid)) { continue; } // Sometimes DTrace ufunc fails and gives no information about symbols if (splits.length < 4) { continue; } long timestamp = Long.parseLong(splits[3]); if (dtraceTimestampBase == 0) { // Use first event timestamp as base for time comparison dtraceTimestampBase = timestamp; continue; } long elapsed = timestamp - dtraceTimestampBase; long elapsedMs = TimeUnit.NANOSECONDS.toMillis(elapsed); if (elapsedMs < start || elapsedMs > end) { continue; } long address = Long.decode(splits[2]); events.add(address); String methodLine = splits[4]; // JIT-compiled code has address instead of symbol information if (methodLine.startsWith("0x")) { continue; } String symbol = "[unknown]"; String[] methodSplit = methodLine.split("`"); String library = methodSplit[0]; if ("".equals(library)) { library = "[unknown]"; } if (methodSplit.length == 2) { symbol = methodSplit[1]; } methods.put(dedup.dedup(MethodDesc.nativeMethod(symbol, library)), address); } IntervalMap methodMap = new IntervalMap<>(); for (MethodDesc md : methods.keys()) { Collection longs = methods.get(md); methodMap.add(md, Utils.min(longs), Utils.max(longs)); } Map> allEvents = new TreeMap<>(); assert requestedEventNames.size() == 1; allEvents.put(requestedEventNames.get(0), events); return new PerfEvents(requestedEventNames, allEvents, methodMap); } catch (IOException e) { throw new RuntimeException(e); } } @Override protected String perfBinaryExtension() { // DTrace produces human-readable txt return ".txt"; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/ExternalProfiler.java000066400000000000000000000074171446271450100271660ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.Result; import java.io.File; import java.util.Collection; /** * External profiler: profilers to be run outside of JVM. * *

External profilers usually call external tools to get the performance data. * It is futile to query any internal JVM facilities in external profiler * Java code, because it may not be executed in the benchmarked VM at all.

*/ public interface ExternalProfiler extends Profiler { /** * Prepend JVM invocation with these commands. * * @param params benchmark parameters used for current launch * @return commands to prepend for JVM launch */ Collection addJVMInvokeOptions(BenchmarkParams params); /** * Add JVM these options to the run. * * @param params benchmark parameters used for current launch * @return options to add to JVM launch */ Collection addJVMOptions(BenchmarkParams params); /** * Run this code before starting the trial. This method will execute * before starting the benchmark JVM. * * @param benchmarkParams benchmark parameters used for current launch */ void beforeTrial(BenchmarkParams benchmarkParams); /** * Run this code after the trial is done. This method will execute * after benchmark JVM had stopped. * * @param br benchmark result that was the result of the trial * @param pid pid that the forked JVM had * @param stdOut file containing the standard output from the benchmark JVM * @param stdErr file containing the standard error from the benchmark JVM * @return profiler results */ Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr); /** * If target VM communicates with profiler with standard output, this method * can be used to shun the output to console. Profiler is responsible for consuming * the standard output and printing the relevant data from there. * * @return returns true, if profiler allows harness to print out the standard output */ boolean allowPrintOut(); /** * If target VM communicates with profiler with standard error, this method * can be used to shun the output to console. Profiler is responsible for consuming * the standard error and printing the relevant data from there. * * @return returns true, if profiler allows harness to print out the standard errpr */ boolean allowPrintErr(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java000066400000000000000000000440131446271450100256660ustar00rootroot00000000000000/* * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; import org.openjdk.jmh.runner.options.IntegerValueConverter; import org.openjdk.jmh.util.HashMultiset; import org.openjdk.jmh.util.Multiset; import javax.management.ListenerNotFoundException; import javax.management.NotificationEmitter; import javax.management.NotificationListener; import javax.management.openmbean.CompositeData; import java.lang.management.*; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; import java.util.concurrent.TimeUnit; public class GCProfiler implements InternalProfiler { private long beforeTime; private long beforeGCCount; private long beforeGCTime; private HotspotAllocationSnapshot beforeAllocated; private boolean churnEnabled; private boolean allocEnabled; private long churnWait; @Override public String getDescription() { return "GC profiling via standard MBeans"; } public GCProfiler(String initLine) throws ProfilerException { OptionParser parser = new OptionParser(); parser.formatHelpWith(new ProfilerOptionFormatter(PausesProfiler.class.getCanonicalName())); OptionSpec optAllocEnable = parser.accepts("alloc", "Enable GC allocation measurement.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(true); OptionSpec optChurnEnable = parser.accepts("churn", "Enable GC churn measurement.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSpec optChurnWait = parser.accepts("churnWait", "Time to wait for churn notifications to arrive.") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("ms").defaultsTo(500); OptionSet set = ProfilerUtils.parseInitLine(initLine, parser); try { churnWait = set.valueOf(optChurnWait); churnEnabled = set.valueOf(optChurnEnable); allocEnabled = set.valueOf(optAllocEnable); } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } if (churnEnabled) { if (!VMSupport.tryInitChurn()) { churnEnabled = false; } } if (allocEnabled) { if (!VMSupport.tryInitAlloc()) { allocEnabled = false; } } } @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { if (churnEnabled) { VMSupport.startChurnProfile(); } long gcTime = 0; long gcCount = 0; for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { gcCount += bean.getCollectionCount(); gcTime += bean.getCollectionTime(); } this.beforeGCCount = gcCount; this.beforeGCTime = gcTime; if (allocEnabled) { this.beforeAllocated = VMSupport.getSnapshot(); } this.beforeTime = System.nanoTime(); } @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult iResult) { long afterTime = System.nanoTime(); if (churnEnabled) { VMSupport.finishChurnProfile(churnWait); } List results = new ArrayList<>(); long gcTime = 0; long gcCount = 0; for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { gcCount += bean.getCollectionCount(); gcTime += bean.getCollectionTime(); } results.add(new ScalarResult( "gc.count", gcCount - beforeGCCount, "counts", AggregationPolicy.SUM)); if (gcCount != beforeGCCount || gcTime != beforeGCTime) { results.add(new ScalarResult( "gc.time", gcTime - beforeGCTime, "ms", AggregationPolicy.SUM)); } if (allocEnabled) { if (beforeAllocated != null) { HotspotAllocationSnapshot newSnapshot = VMSupport.getSnapshot(); long allocated = newSnapshot.difference(beforeAllocated); // When no allocations measured, we still need to report results to avoid user confusion results.add(new ScalarResult("gc.alloc.rate", (afterTime != beforeTime) ? 1.0 * allocated / 1024 / 1024 * TimeUnit.SECONDS.toNanos(1) / (afterTime - beforeTime) : Double.NaN, "MB/sec", AggregationPolicy.AVG)); if (allocated != 0) { long allOps = iResult.getMetadata().getAllOps(); results.add(new ScalarResult("gc.alloc.rate.norm", (allOps != 0) ? 1.0 * allocated / allOps : Double.NaN, "B/op", AggregationPolicy.AVG)); } } else { // When allocation profiling fails, make sure it is distinguishable in report results.add(new ScalarResult("gc.alloc.rate", Double.NaN, "MB/sec", AggregationPolicy.AVG)); } } if (churnEnabled) { Multiset churn = VMSupport.getChurn(); for (String space : churn.keys()) { double churnRate = (afterTime != beforeTime) ? 1.0 * churn.count(space) * TimeUnit.SECONDS.toNanos(1) / (afterTime - beforeTime) / 1024 / 1024 : Double.NaN; double churnNorm = 1.0 * churn.count(space) / iResult.getMetadata().getAllOps(); String spaceName = space.replaceAll(" ", "_"); results.add(new ScalarResult( "gc.churn." + spaceName + "", churnRate, "MB/sec", AggregationPolicy.AVG)); results.add(new ScalarResult( "gc.churn." + spaceName + ".norm", churnNorm, "B/op", AggregationPolicy.AVG)); } } return results; } interface HotspotAllocationSnapshot { long difference(HotspotAllocationSnapshot before); } static class GlobalHotspotAllocationSnapshot implements HotspotAllocationSnapshot { private final long allocatedBytes; public GlobalHotspotAllocationSnapshot(long allocatedBytes) { this.allocatedBytes = allocatedBytes; } @Override public long difference(HotspotAllocationSnapshot before) { if (!(before instanceof GlobalHotspotAllocationSnapshot)) { throw new IllegalArgumentException(); } GlobalHotspotAllocationSnapshot other = (GlobalHotspotAllocationSnapshot) before; long beforeAllocs = other.allocatedBytes; if (allocatedBytes >= beforeAllocs) { return allocatedBytes - beforeAllocs; } else { // Do not allow negative values return 0; } } } static class PerThreadHotspotAllocationSnapshot implements HotspotAllocationSnapshot { private final long[] threadIds; private final long[] allocatedBytes; private PerThreadHotspotAllocationSnapshot(long[] threadIds, long[] allocatedBytes) { this.threadIds = threadIds; this.allocatedBytes = allocatedBytes; } /** * Estimates allocated bytes based on two snapshots. * The problem is threads can come and go while performing the benchmark, * thus we would miss allocations made in a thread that was created and died between the snapshots. *

*

Current thread is intentionally excluded since it believed to execute jmh infrastructure code only. * * @return estimated number of allocated bytes between profiler calls */ public long difference(HotspotAllocationSnapshot before) { if (!(before instanceof PerThreadHotspotAllocationSnapshot)) { throw new IllegalArgumentException(); } PerThreadHotspotAllocationSnapshot other = (PerThreadHotspotAllocationSnapshot) before; HashMap prevIndex = new HashMap<>(); for (int i = 0; i < other.threadIds.length; i++) { long id = other.threadIds[i]; prevIndex.put(id, i); } long currentThreadId = Thread.currentThread().getId(); long allocated = 0; for (int i = 0; i < threadIds.length; i++) { long id = threadIds[i]; if (id == currentThreadId) { continue; } allocated += allocatedBytes[i]; Integer prev = prevIndex.get(id); if (prev != null) { allocated -= other.allocatedBytes[prev]; } } return allocated; } } /** * This class encapsulates any platform-specific functionality. It is supposed to gracefully * fail if some functionality is not available. This class resolves most special classes via * Reflection to enable building against a standard JDK. */ static class VMSupport { private static ThreadMXBean ALLOC_MX_BEAN; private static Method ALLOC_MX_BEAN_GETTER_PER_THREAD; private static Method ALLOC_MX_BEAN_GETTER_GLOBAL; private static NotificationListener LISTENER; private static Multiset CHURN; private static boolean tryInitAlloc() { try { Class internalIntf = Class.forName("com.sun.management.ThreadMXBean"); ThreadMXBean bean = ManagementFactory.getThreadMXBean(); if (!internalIntf.isAssignableFrom(bean.getClass())) { Class pmo = Class.forName("java.lang.management.PlatformManagedObject"); Method m = ManagementFactory.class.getMethod("getPlatformMXBean", Class.class, pmo); bean = (ThreadMXBean) m.invoke(null, internalIntf); if (bean == null) { throw new UnsupportedOperationException("No way to access private ThreadMXBean"); } } ALLOC_MX_BEAN = bean; // See if global getter is available in this JVM try { ALLOC_MX_BEAN_GETTER_GLOBAL = internalIntf.getMethod("getTotalThreadAllocatedBytes"); getSnapshot(); return true; } catch (Exception e) { // Fall through } // See if per-thread getter is available in this JVM ALLOC_MX_BEAN_GETTER_PER_THREAD = internalIntf.getMethod("getThreadAllocatedBytes", long[].class); getSnapshot(); return true; } catch (Throwable e) { System.out.println("Allocation profiling is not available: " + e.getMessage()); } return false; } private static boolean tryInitChurn() { try { for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { if (!(bean instanceof NotificationEmitter)) { throw new UnsupportedOperationException("GarbageCollectorMXBean cannot notify"); } } CHURN = new HashMultiset<>(); LISTENER = newListener(); return true; } catch (Throwable e) { System.out.println("Churn profiling is not available: " + e.getMessage()); } return false; } private static NotificationListener newListener() { try { final Class infoKlass = Class.forName("com.sun.management.GarbageCollectionNotificationInfo"); final Field notifNameField = infoKlass.getField("GARBAGE_COLLECTION_NOTIFICATION"); final Method infoMethod = infoKlass.getMethod("from", CompositeData.class); final Method getGcInfo = infoKlass.getMethod("getGcInfo"); final Method getMemoryUsageBeforeGc = getGcInfo.getReturnType().getMethod("getMemoryUsageBeforeGc"); final Method getMemoryUsageAfterGc = getGcInfo.getReturnType().getMethod("getMemoryUsageAfterGc"); return (n, o) -> { try { if (n.getType().equals(notifNameField.get(null))) { Object info = infoMethod.invoke(null, n.getUserData()); Object gcInfo = getGcInfo.invoke(info); Map mapBefore = (Map) getMemoryUsageBeforeGc.invoke(gcInfo); Map mapAfter = (Map) getMemoryUsageAfterGc.invoke(gcInfo); for (Map.Entry entry : mapAfter.entrySet()) { String name = entry.getKey(); MemoryUsage after = entry.getValue(); MemoryUsage before = mapBefore.get(name); long c = before.getUsed() - after.getUsed(); if (c > 0) { CHURN.add(name, c); } } } } catch (IllegalAccessException | InvocationTargetException e) { // Do nothing, counters would not get populated } }; } catch (Throwable e) { throw new IllegalStateException(e); } } public static HotspotAllocationSnapshot getSnapshot() { // Try the global getter first, if available if (ALLOC_MX_BEAN_GETTER_GLOBAL != null) { try { long allocatedBytes = (long) ALLOC_MX_BEAN_GETTER_GLOBAL.invoke(ALLOC_MX_BEAN); if (allocatedBytes == -1L) { throw new IllegalStateException("getTotalThreadAllocatedBytes is disabled"); } return new GlobalHotspotAllocationSnapshot(allocatedBytes); } catch (InvocationTargetException | IllegalAccessException e) { throw new IllegalStateException(e); } } // Fall back to per-thread getter long[] threadIds = ALLOC_MX_BEAN.getAllThreadIds(); try { long[] allocatedBytes = (long[]) ALLOC_MX_BEAN_GETTER_PER_THREAD.invoke(ALLOC_MX_BEAN, (Object) threadIds); return new PerThreadHotspotAllocationSnapshot(threadIds, allocatedBytes); } catch (InvocationTargetException | IllegalAccessException e) { throw new IllegalStateException(e); } } public static synchronized void startChurnProfile() { CHURN.clear(); try { for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { ((NotificationEmitter) bean).addNotificationListener(LISTENER, null, null); } } catch (Exception e) { throw new IllegalStateException("Should not be here"); } } public static synchronized void finishChurnProfile(long churnWait) { // Notifications are asynchronous, need to wait a bit before deregistering the listener. try { Thread.sleep(churnWait); } catch (InterruptedException e) { // do not care } for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { try { ((NotificationEmitter) bean).removeNotificationListener(LISTENER); } catch (ListenerNotFoundException e) { // Do nothing } } } public static synchronized Multiset getChurn() { return (CHURN != null) ? CHURN : new HashMultiset<>(); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/InternalProfiler.java000066400000000000000000000045651446271450100271610ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.results.Result; import java.util.Collection; /** * Internal profiler. * *

Internal profilers run in the benchmark JVM, and may query the internal * JVM facilities.

*/ public interface InternalProfiler extends Profiler { /** * Run this code before starting the next benchmark iteration. * * @param benchmarkParams benchmark parameters used for current launch * @param iterationParams iteration parameters used for current launch */ void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams); /** * Run this code after a benchmark iteration finished * * @param benchmarkParams benchmark parameters used for current launch * @param iterationParams iteration parameters used for current launch * @param result iteration result * @return profiler results */ Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/JavaFlightRecorderProfiler.java000066400000000000000000000245711446271450100311110ustar00rootroot00000000000000/* * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.TextResult; import org.openjdk.jmh.runner.IterationType; import org.openjdk.jmh.util.JDKVersion; import org.openjdk.jmh.util.Utils; import java.io.File; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; /** * A profiler based on Java Flight Recorder. * * @author Jason Zaugg */ public final class JavaFlightRecorderProfiler implements ExternalProfiler, InternalProfiler { private final boolean verbose; private final File outDir; private final boolean debugNonSafePoints; private final String configName; private final Collection flightRecorderOptions = new ArrayList<>(); private PostProcessor postProcessor = null; private boolean measurementStarted = false; private int measurementIterationCount; private String profileName; private final List generated = new ArrayList<>(); public JavaFlightRecorderProfiler(String initLine) throws ProfilerException { OptionParser parser = new OptionParser(); parser.formatHelpWith(new ProfilerOptionFormatter("jfr")); OptionSpec optDir = parser.accepts("dir", "Output directory.") .withRequiredArg().ofType(String.class).describedAs("dir"); OptionSpec optConfig = parser.accepts("configName", "Name of a predefined Flight Recorder configuration, e.g. profile or default") .withRequiredArg().ofType(String.class).describedAs("name").defaultsTo("profile"); OptionSpec optDebugNonSafePoints = parser.accepts("debugNonSafePoints", "Gather cpu samples asynchronously, rather than at the subsequent safepoint.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(true); OptionSpec optStackDepth = parser.accepts("stackDepth", "Maximum number of stack frames collected for each event.") .withRequiredArg().ofType(Integer.class).describedAs("frames"); OptionSpec optPostProcessor = parser.accepts("postProcessor", "The fully qualified name of a class that implements " + PostProcessor.class + ". " + "This must have a public, no-argument constructor.") .withRequiredArg().ofType(String.class).describedAs("fqcn"); OptionSpec optVerbose = parser.accepts("verbose", "Output the sequence of commands") .withRequiredArg().ofType(Boolean.class).defaultsTo(false).describedAs("bool"); OptionSet set = ProfilerUtils.parseInitLine(initLine, parser); try { this.debugNonSafePoints = optDebugNonSafePoints.value(set); this.configName = optConfig.value(set); if (set.has(optStackDepth)) { flightRecorderOptions.add("stackdepth=" + optStackDepth.value(set)); } verbose = optVerbose.value(set); if (!set.has(optDir)) { outDir = new File(System.getProperty("user.dir")); } else { outDir = new File(set.valueOf(optDir)); } if (set.has(optPostProcessor)) { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class postProcessorClass = loader.loadClass(optPostProcessor.value(set)); postProcessor = (PostProcessor) postProcessorClass.getDeclaredConstructor().newInstance(); } catch (ReflectiveOperationException e) { throw new ProfilerException(e); } } } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } } @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { if (iterationParams.getType() == IterationType.MEASUREMENT) { if (!measurementStarted) { profileName = benchmarkParams.id(); execute(benchmarkParams.getJvm(), "JFR.start", Collections.singletonList("settings=" + configName)); measurementStarted = true; } } } @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult iterationResult) { if (iterationParams.getType() == IterationType.MEASUREMENT) { measurementIterationCount += 1; if (measurementIterationCount == iterationParams.getCount()) { File trialOutDir = createTrialOutDir(benchmarkParams); File jfrFile = new File(trialOutDir, "profile.jfr"); String filenameOption = "filename=" + jfrFile.getAbsolutePath(); execute(benchmarkParams.getJvm(), "JFR.stop", Collections.singletonList(filenameOption)); generated.add(jfrFile); if (postProcessor != null) { generated.addAll(postProcessor.postProcess(benchmarkParams, jfrFile)); } return Collections.singletonList(result()); } } return Collections.emptyList(); } private TextResult result() { StringWriter output = new StringWriter(); PrintWriter pw = new PrintWriter(output); pw.println("JFR profiler results:"); for (File file : generated) { pw.print(" "); pw.println(file.getPath()); } pw.flush(); pw.close(); return new TextResult(output.toString(), "jfr"); } private File createTrialOutDir(BenchmarkParams benchmarkParams) { String fileName = benchmarkParams.id(); File trialOutDir = new File(this.outDir, fileName); trialOutDir.mkdirs(); return trialOutDir; } private void execute(String jvm, String cmd, Collection options) { long pid = Utils.getPid(); ArrayList fullCommand = new ArrayList<>(); fullCommand.add(findJcmd(jvm).getAbsolutePath()); fullCommand.add(String.valueOf(pid)); fullCommand.add(cmd); fullCommand.add("name=" + profileName); fullCommand.addAll(options); if (verbose) { System.out.println("[jfr] " + fullCommand); } // TODO Use JMX to control FlightRecorder when the baseline of JDK support in JMH // advances to a version with that included. Collection errorOutput = Utils.tryWith(fullCommand.toArray(new String[0])); if (!errorOutput.isEmpty()) { throw new RuntimeException("Error executing: " + fullCommand + System.lineSeparator() + Utils.join(errorOutput, System.lineSeparator())); } } private File findJcmd(String jvm) { // Try 1: same directory as JVM binary File bin = new File(jvm).getParentFile(); { File jcmd = new File(bin, "jcmd" + (Utils.isWindows() ? ".exe" : "")); if (jcmd.exists()) { return jcmd; } } // Try 2: parent bin/ directory { final String s = File.separator; File jcmd = new File(bin, ".." + s + ".." + s + "bin" + s + "jcmd" + (Utils.isWindows() ? ".exe" : "")); if (jcmd.exists()) { return jcmd; } } // No dice. throw new IllegalStateException("Cannot find jcmd anywhere"); } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public Collection addJVMOptions(BenchmarkParams params) { List args = new ArrayList<>(); if (debugNonSafePoints) { args.add("-XX:+UnlockDiagnosticVMOptions"); args.add("-XX:+DebugNonSafepoints"); } if (!flightRecorderOptions.isEmpty()) { args.add("-XX:FlightRecorderOptions=" + Utils.join(flightRecorderOptions, ",")); } // JDK 13+ does not need need the opt-in if (JDKVersion.parseMajor(params.getJdkVersion()) < 13) { args.add("-XX:+FlightRecorder"); } return args; } @Override public void beforeTrial(BenchmarkParams benchmarkParams) { } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { return Collections.emptyList(); } @Override public boolean allowPrintOut() { return true; } @Override public boolean allowPrintErr() { return true; } @Override public String getDescription() { return "Java Flight Recorder profiler"; } public interface PostProcessor { List postProcess(BenchmarkParams benchmarkParams, File jfrFile); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java000066400000000000000000000245241446271450100277570ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.util.*; import java.io.BufferedReader; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.math.BigInteger; import java.util.*; public class LinuxPerfAsmProfiler extends AbstractPerfAsmProfiler { private final String sampleFrequency; private OptionSpec optFrequency; public LinuxPerfAsmProfiler(String initLine) throws ProfilerException { super(initLine, "cycles"); String[] senseCmd = { PerfSupport.PERF_EXEC, "stat", "--event", Utils.join(requestedEventNames, ","), "--log-fd", "2", "echo", "1" }; Collection failMsg = Utils.tryWith(senseCmd); if (!failMsg.isEmpty()) { throw new ProfilerException(failMsg.toString()); } Collection passMsg = Utils.runWith(senseCmd); for (String ev : requestedEventNames) { if (PerfSupport.containsUnsupported(passMsg, ev)) { throw new ProfilerException("Unsupported event: " + ev); } } try { sampleFrequency = set.valueOf(optFrequency); } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } } @Override protected void addMyOptions(OptionParser parser) { optFrequency = parser.accepts("frequency", "Sampling frequency, synonymous to perf record --freq #; " + "use \"max\" for highest sampling rate possible on the system.") .withRequiredArg().ofType(String.class).describedAs("freq").defaultsTo("1000"); } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { return Arrays.asList(PerfSupport.PERF_EXEC, "record", "--freq", String.valueOf(sampleFrequency), "--event", Utils.join(requestedEventNames, ","), "--output", perfBinData.getAbsolutePath()); } @Override public String getDescription() { return "Linux perf + PrintAssembly Profiler"; } @Override protected void parseEvents() { try (FileOutputStream fos = new FileOutputStream(perfParsedData.file())) { ProcessBuilder pb = new ProcessBuilder(PerfSupport.PERF_EXEC, "script", "--fields", "time,event,ip,sym,dso", "--input", perfBinData.getAbsolutePath()); Process p = pb.start(); // drain streams, else we might lock up InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), fos); InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), fos); errDrainer.start(); outDrainer.start(); p.waitFor(); errDrainer.join(); outDrainer.join(); } catch (IOException | InterruptedException ex) { throw new IllegalStateException(ex); } } static PerfLine parsePerfLine(String line) { if (line.startsWith("#")) { return null; } // Demangled symbol names can contain spaces, so we need to parse the lines // in a complicated manner. Using regexps will not solve this without sacrificing // lots of performance, so we need to get tricky. // // We are forcing perf to print: time event ip sym dso // // 328992.235251: instructions: 7fa85da61a09 match_symbol (/lib/x86_64-linux-gnu/ld-2.23.so) // // Remove excess spaces int lastLength = -1; while (line.length() != lastLength) { lastLength = line.length(); line = line.replace(" ", " "); } // Chomp the time int timeIdx = line.indexOf(": "); if (timeIdx == -1) return null; String strTime = line.substring(0, timeIdx); line = line.substring(timeIdx + 2); double time; try { time = Double.parseDouble(strTime); } catch (NumberFormatException e) { return null; } // Chomp the library, handling spaces properly: int libIdx = line.lastIndexOf(" ("); if (libIdx == -1) return null; String lib = line.substring(libIdx); lib = lib.substring(lib.lastIndexOf("/") + 1).replace("(", "").replace(")", ""); line = line.substring(0, libIdx); // Chomp the event name: int evIdx = line.indexOf(": "); if (evIdx == -1) return null; String evName = line.substring(0, evIdx); int tagIdx = evName.lastIndexOf(":"); if (tagIdx != -1) { evName = evName.substring(0, tagIdx); } line = line.substring(evIdx + 2); // Chomp the addr: int addrIdx = line.indexOf(" "); if (addrIdx == -1) return null; String strAddr = line.substring(0, addrIdx); line = line.substring(addrIdx + 1); // Try to parse the positive address lightly first. // If that fails, try to parse the negative address. // If that fails as well, then address is unresolvable. long addr; try { addr = Long.parseLong(strAddr, 16); } catch (NumberFormatException e) { try { addr = new BigInteger(strAddr, 16).longValue(); if (addr < 0L && lib.contains("unknown")) { lib = "kernel"; } } catch (NumberFormatException e1) { addr = 0L; } } // Whatever is left is symbol: String symbol = line; return new PerfLine(time, evName, addr, symbol, lib); } static class PerfLine { final double time; final String event; final long addr; final String symbol; final String lib; public PerfLine(double time, String event, long addr, String symbol, String lib) { this.time = time; this.event = event; this.addr = addr; this.symbol = symbol; this.lib = lib; } public double time() { return time; } public String eventName() { return event; } public long addr() { return addr; } public String symbol() { return symbol; } public String lib() { return lib; } } @Override protected PerfEvents readEvents(double skipMs, double lenMs) { double readFrom = skipMs / 1000D; double readTo = (skipMs + lenMs) / 1000D; List evNames = stripEventNames(requestedEventNames); try (FileReader fr = new FileReader(perfParsedData.file()); BufferedReader reader = new BufferedReader(fr)) { Deduplicator dedup = new Deduplicator<>(); Multimap methods = new HashMultimap<>(); Map> events = new LinkedHashMap<>(); for (String evName : evNames) { events.put(evName, new TreeMultiset<>()); } Double startTime = null; String line; while ((line = reader.readLine()) != null) { PerfLine perfline = parsePerfLine(line); if (perfline == null) { continue; } if (startTime == null) { startTime = perfline.time(); } else { if (perfline.time() - startTime < readFrom) { continue; } if (perfline.time() - startTime > readTo) { continue; } } Multiset evs = events.get(perfline.eventName()); if (evs == null) { // we are not prepared to handle this event, skip continue; } evs.add(perfline.addr()); MethodDesc desc = dedup.dedup(MethodDesc.nativeMethod(perfline.symbol(), perfline.lib())); methods.put(desc, perfline.addr()); } IntervalMap methodMap = new IntervalMap<>(); for (MethodDesc md : methods.keys()) { Collection addrs = methods.get(md); methodMap.add(md, Utils.min(addrs), Utils.max(addrs)); } return new PerfEvents(evNames, events, methodMap); } catch (IOException e) { throw new RuntimeException(e); } } @Override protected String perfBinaryExtension() { return ".perfbin"; } @Override protected List stripEventNames(List events) { return stripPerfEventNames(events); } static List stripPerfEventNames(List events) { List res = new ArrayList<>(); for (String ev : events) { int tagIdx = ev.indexOf(':'); if (tagIdx != -1) { res.add(ev.substring(0, tagIdx)); } else { res.add(ev); } } return res; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfC2CProfiler.java000066400000000000000000000074341446271450100276070ustar00rootroot00000000000000/* * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.TextResult; import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.TempFile; import org.openjdk.jmh.util.Utils; import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.concurrent.TimeUnit; public final class LinuxPerfC2CProfiler implements ExternalProfiler { protected final TempFile perfBinData; public LinuxPerfC2CProfiler() throws ProfilerException { Collection failMsg = Utils.tryWith(PerfSupport.PERF_EXEC, "c2c", "record", "echo", "1"); if (!failMsg.isEmpty()) { throw new ProfilerException(failMsg.toString()); } try { perfBinData = FileUtils.weakTempFile("perf-c2c-bin"); } catch (IOException e) { throw new ProfilerException(e); } } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { long delay = TimeUnit.NANOSECONDS.toMillis(params.getWarmup().getCount() * params.getWarmup().getTime().convertTo(TimeUnit.NANOSECONDS)) + TimeUnit.SECONDS.toMillis(1); // loosely account for the JVM lag return Arrays.asList("perf", "c2c", "record", "-o", perfBinData.getAbsolutePath(), "--", "--delay", String.valueOf(delay)); } @Override public Collection addJVMOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public void beforeTrial(BenchmarkParams params) {} @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { try { Process process = new ProcessBuilder("perf", "c2c", "report", "--stats", "-i", perfBinData.getAbsolutePath()) .redirectErrorStream(true) .start(); Collection lines = FileUtils.readAllLines(process.getInputStream()); String out = Utils.join(lines, System.lineSeparator()); return Collections.singleton(new TextResult(out, "perfc2c")); } catch (IOException e) { throw new RuntimeException(e); } } @Override public boolean allowPrintOut() { return false; } @Override public boolean allowPrintErr() { return false; } @Override public String getDescription() { return "Linux perf c2c profiler"; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java000066400000000000000000000341401446271450100301450ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.*; import org.openjdk.jmh.util.*; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.text.NumberFormat; import java.text.ParseException; import java.util.*; public class LinuxPerfNormProfiler implements ExternalProfiler { /** This is a non-exhaustive list of events we care about. */ private static final String[] interestingEvents = new String[]{ "cycles", "instructions", "branches", "branch-misses", "L1-dcache-loads", "L1-dcache-load-misses", "L1-dcache-stores", "L1-dcache-store-misses", "L1-icache-loads", "L1-icache-load-misses", "LLC-loads", "LLC-load-misses", "LLC-stores", "LLC-store-misses", "dTLB-loads", "dTLB-load-misses", "dTLB-stores", "dTLB-store-misses", "iTLB-loads", "iTLB-load-misses", "stalled-cycles-frontend", "stalled-cycles-backend", }; private final int delayMs; private final int lengthMs; private final boolean useDefaultStats; private final int incrementInterval; private final boolean doFilter; private final Collection supportedEvents = new ArrayList<>(); public LinuxPerfNormProfiler(String initLine) throws ProfilerException { OptionParser parser = new OptionParser(); parser.formatHelpWith(new ProfilerOptionFormatter("perfnorm")); OptionSpec optEvents = parser.accepts("events", "Events to gather.") .withRequiredArg().ofType(String.class).withValuesSeparatedBy(",").describedAs("event+"); OptionSpec optDelay = parser.accepts("delay", "Delay collection for a given time, in milliseconds; -1 to detect automatically.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); OptionSpec optLength = parser.accepts("length", "Do the collection for a given time, in milliseconds; -1 to detect automatically.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); OptionSpec optIncrementInterval = parser.accepts("interval", "The interval between incremental updates from a concurrently running perf. " + "Lower values may improve accuracy, while increasing the profiling overhead.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(100); OptionSpec optFilter = parser.accepts("filter", "Filter problematic samples from infrastructure and perf itself.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(true); OptionSpec optDefaultStat = parser.accepts("useDefaultStat", "Use \"perf stat -d -d -d\" instead of explicit counter list.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSet set = ProfilerUtils.parseInitLine(initLine, parser); Collection userEvents; try { delayMs = set.valueOf(optDelay); lengthMs = set.valueOf(optLength); incrementInterval = set.valueOf(optIncrementInterval); doFilter = set.valueOf(optFilter); useDefaultStats = set.valueOf(optDefaultStat); userEvents = set.valuesOf(optEvents); } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } Collection msgs = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "echo", "1"); if (!msgs.isEmpty()) { throw new ProfilerException(msgs.toString()); } Collection incremental = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--interval-print", String.valueOf(incrementInterval), "echo", "1"); if (!incremental.isEmpty()) { throw new ProfilerException("\\\"perf\\\" is too old, needs incremental mode (-I)."); } Collection candidateEvents = new ArrayList<>(); if (userEvents != null) { for (String ev : userEvents) { if (ev.trim().isEmpty()) continue; candidateEvents.add(ev); } } if (candidateEvents.isEmpty()) { candidateEvents.addAll(Arrays.asList(interestingEvents)); } for (String ev : candidateEvents) { String[] senseCmd = { PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--event", ev, "echo", "1" }; Collection res = Utils.tryWith(senseCmd); if (res.isEmpty()) { Collection out = Utils.runWith(senseCmd); if (!PerfSupport.containsUnsupported(out, ev)) { supportedEvents.add(ev); } } } if (!useDefaultStats && supportedEvents.isEmpty()) { throw new ProfilerException("No supported events."); } } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { List cmd = new ArrayList<>(); if (useDefaultStats) { cmd.addAll(Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--detailed", "--detailed", "--detailed")); } else { cmd.addAll(Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--event", Utils.join(supportedEvents, ","))); } cmd.addAll(Arrays.asList("-I", String.valueOf(incrementInterval))); return cmd; } @Override public Collection addJVMOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public void beforeTrial(BenchmarkParams params) { // do nothing } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { return process(br, stdOut, stdErr); } @Override public boolean allowPrintOut() { return true; } @Override public boolean allowPrintErr() { return false; } @Override public String getDescription() { return "Linux perf statistics, normalized by operation count"; } private static class EventRecord { final double time; final double value; public EventRecord(double time, double value) { this.time = time; this.value = value; } } private Collection process(BenchmarkResult br, File stdOut, File stdErr) { Multimap eventRecords = new HashMultimap<>(); try (FileReader fr = new FileReader(stdErr); BufferedReader reader = new BufferedReader(fr)) { long skipMs; if (delayMs == -1) { // not set skipMs = ProfilerUtils.measurementDelayMs(br); } else { skipMs = delayMs; } double lenMs; if (lengthMs == -1) { // not set lenMs = ProfilerUtils.measuredTimeMs(br); } else { lenMs = lengthMs; } double readFrom = skipMs / 1000D; double readTo = (skipMs + lenMs + incrementInterval) / 1000D; NumberFormat nf = NumberFormat.getInstance(); String line; while ((line = reader.readLine()) != null) { if (line.startsWith("#")) continue; String[] split = line.split(","); String time; String count; String event; if (split.length == 3) { // perf 3.13: time,count,event time = split[0].trim(); count = split[1].trim(); event = split[2].trim(); } else if (split.length >= 4) { // perf >3.13: time,count,,event, time = split[0].trim(); count = split[1].trim(); event = split[3].trim(); } else { // Malformed line, ignore continue; } double timeSec = 0D; try { timeSec = nf.parse(time).doubleValue(); } catch (ParseException e) { continue; } if (timeSec < readFrom || timeSec > readTo) { // Outside measurement window, ignore continue; } long lValue = 0L; try { lValue = nf.parse(count).longValue(); } catch (ParseException e) { continue; } eventRecords.put(event, new EventRecord(timeSec, lValue)); } Map finalThroughputs = new HashMap<>(); for (String key : eventRecords.keys()) { List countedEvents = new ArrayList<>(eventRecords.get(key)); // If needed and possible, filter out a few head and tail iterations. // Head iteration potentially contains the infrastructure startup. // That iteration would only be handled for getting time, not the counter itself. // Trailing iterations come with both infrastructure rampdown, and the final // profiler output on shutdown. Sometimes these manifest as two separate iterations. final int filteredCount = countedEvents.size() - 2; if (doFilter && filteredCount > 0) { countedEvents = countedEvents.subList(0, filteredCount); } double s = 0; double minTime = Double.MAX_VALUE; double maxTime = Double.MIN_VALUE; for (int i = 0; i < countedEvents.size(); i++) { EventRecord v = countedEvents.get(i); if (i != 0) { // Do not count the first event in the series, since time interval // does not actually include it. s += v.value; } minTime = Math.min(minTime, v.time); maxTime = Math.max(maxTime, v.time); } double thr = s / (maxTime - minTime); finalThroughputs.put(key, thr); } BenchmarkResultMetaData md = br.getMetadata(); if (md == null) { return emptyResults(); } long timeMs = md.getStopTime() - md.getMeasurementTime(); if (timeMs == 0) { return emptyResults(); } double opsThroughput = 1000D * md.getMeasurementOps() / timeMs; if (opsThroughput == 0) { return emptyResults(); } Collection results = new ArrayList<>(); for (String key : finalThroughputs.keySet()) { results.add(new PerfResult(key, "#/op", finalThroughputs.get(key) / opsThroughput)); } // Also figure out IPC/CPI, if enough counters available: { Double c1 = finalThroughputs.get("cycles"); Double c2 = finalThroughputs.get("cycles:u"); Double i1 = finalThroughputs.get("instructions"); Double i2 = finalThroughputs.get("instructions:u"); Double cycles = (c1 != null) ? c1 : c2; Double instructions = (i1 != null) ? i1 : i2; if (cycles != null && instructions != null && cycles != 0 && instructions != 0) { results.add(new PerfResult("CPI", "clks/insn", cycles / instructions)); results.add(new PerfResult("IPC", "insns/clk", instructions / cycles)); } } return results; } catch (IOException e) { throw new IllegalStateException(e); } } private static Set emptyResults() { return Collections.singleton(new PerfResult("N/A", "", Double.NaN)); } static class PerfResult extends ScalarResult { private static final long serialVersionUID = -1262685915873231436L; public PerfResult(String key, String unit, double value) { super(key, value, unit, AggregationPolicy.AVG); } @Override public String extendedInfo() { // omit printing in extended info return ""; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java000066400000000000000000000225611446271450100273150ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.*; import org.openjdk.jmh.util.ScoreFormatter; import org.openjdk.jmh.util.Utils; import java.io.*; import java.text.NumberFormat; import java.text.ParseException; import java.util.Arrays; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; public class LinuxPerfProfiler implements ExternalProfiler { private final boolean isDelayed; private final int delayMs; private final List events; public LinuxPerfProfiler(String initLine) throws ProfilerException { OptionParser parser = new OptionParser(); parser.formatHelpWith(new ProfilerOptionFormatter("perf")); OptionSpec optDelay = parser.accepts("delay", "Delay collection for a given time, in milliseconds; -1 to detect automatically.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); OptionSpec optEvents = parser.accepts("events", "Events to gather.") .withRequiredArg().ofType(String.class).withValuesSeparatedBy(",").describedAs("event"); OptionSet set = ProfilerUtils.parseInitLine(initLine, parser); try { events = set.valuesOf(optEvents); delayMs = set.valueOf(optDelay); } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } Collection msgs = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "echo", "1"); if (!msgs.isEmpty()) { throw new ProfilerException(msgs.toString()); } Collection delay = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--delay", "1", "echo", "1"); isDelayed = delay.isEmpty(); } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { long delay; if (delayMs == -1) { // not set delay = TimeUnit.NANOSECONDS.toMillis(params.getWarmup().getCount() * params.getWarmup().getTime().convertTo(TimeUnit.NANOSECONDS)) + TimeUnit.SECONDS.toMillis(1); // loosely account for the JVM lag } else { delay = delayMs; } List invokeOptions = new ArrayList<>(Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--detailed", "--detailed", "--detailed")); if (isDelayed) { invokeOptions.add("--delay"); invokeOptions.add(String.valueOf(delay)); } if (!events.isEmpty()) { invokeOptions.add("-e"); invokeOptions.add(Utils.join(events, ",")); } return invokeOptions; } @Override public Collection addJVMOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public void beforeTrial(BenchmarkParams params) { // do nothing } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { PerfResult result = process(stdOut, stdErr); return Collections.singleton(result); } @Override public boolean allowPrintOut() { return true; } @Override public boolean allowPrintErr() { return false; } @Override public String getDescription() { return "Linux perf Statistics"; } private PerfResult process(File stdOut, File stdErr) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); final Pattern hashLinePattern = Pattern.compile("(.*)#(.*)"); try (FileReader fr = new FileReader(stdErr); BufferedReader reader = new BufferedReader(fr)) { long cycles = 0; long insns = 0; boolean printing = false; String line; while ((line = reader.readLine()) != null) { if (printing) { pw.println(line); } if (line.contains("Performance counter stats")) { printing = true; } Matcher m = hashLinePattern.matcher(line); if (m.matches()) { String pair = m.group(1).trim(); if (pair.contains(" cycles")) { try { cycles = NumberFormat.getInstance().parse(pair.split("[ ]+")[0]).longValue(); } catch (ParseException e) { // do nothing, processing code will handle } } if (line.contains(" instructions")) { try { insns = NumberFormat.getInstance().parse(pair.split("[ ]+")[0]).longValue(); } catch (ParseException e) { // do nothing, processing code will handle } } } } if (!isDelayed) { pw.println(); pw.println("WARNING: Your system uses old \"perf\", which can not delay data collection.\n" + "Therefore, perf performance data includes benchmark warmup."); } pw.flush(); pw.close(); return new PerfResult( sw.toString(), cycles, insns ); } catch (IOException e) { throw new IllegalStateException(e); } } static class PerfResult extends Result { private static final long serialVersionUID = -1262685915873231436L; private final String output; private final long cycles; private final long instructions; public PerfResult(String output, long cycles, long instructions) { super(ResultRole.SECONDARY, "perf", of(Double.NaN), "---", AggregationPolicy.AVG); this.output = output; this.cycles = cycles; this.instructions = instructions; } @Override protected Aggregator getThreadAggregator() { return new PerfResultAggregator(); } @Override protected Aggregator getIterationAggregator() { return new PerfResultAggregator(); } @Override protected Collection getDerivativeResults() { List res = new ArrayList<>(); if (cycles != 0 && instructions != 0) { res.add(new ScalarDerivativeResult("ipc", 1.0 * instructions / cycles, "insns/clk", AggregationPolicy.AVG)); res.add(new ScalarDerivativeResult("cpi", 1.0 * cycles / instructions, "clks/insn", AggregationPolicy.AVG)); } return res; } @Override public String toString() { if (cycles != 0 && instructions != 0) { return String.format("%s IPC, %s CPI", ScoreFormatter.format(1.0 * instructions / cycles), ScoreFormatter.format(1.0 * cycles / instructions)); } else { return "N/A"; } } @Override public String extendedInfo() { return "Perf stats:\n--------------------------------------------------\n" + output; } } static class PerfResultAggregator implements Aggregator { @Override public PerfResult aggregate(Collection results) { long cycles = 0; long instructions = 0; String output = ""; for (PerfResult r : results) { cycles += r.cycles; instructions += r.instructions; output += r.output; } return new PerfResult(output, cycles, instructions); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/MemPoolProfiler.java000066400000000000000000000057111446271450100267470ustar00rootroot00000000000000/* * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; import java.lang.management.MemoryPoolMXBean; import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.Collection; import java.util.List; public class MemPoolProfiler implements InternalProfiler { static final double BYTES_PER_KIB = 1024D; @Override public String getDescription() { return "Memory pool/footprint profiling via standard MBeans"; } @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { for (MemoryPoolMXBean b : ManagementFactory.getMemoryPoolMXBeans()) { b.resetPeakUsage(); } } @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { List results = new ArrayList<>(); long sumCodeHeap = 0L; long sum = 0L; for (MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) { long used = bean.getPeakUsage().getUsed(); if (bean.getName().contains("CodeHeap") || bean.getName().contains("Code Cache")) { sumCodeHeap += used; } sum += used; results.add(new ScalarResult("mempool." + bean.getName() + ".used", used / BYTES_PER_KIB, "KiB", AggregationPolicy.MAX)); } results.add(new ScalarResult("mempool.total.codeheap.used", sumCodeHeap / BYTES_PER_KIB, "KiB", AggregationPolicy.MAX)); results.add(new ScalarResult("mempool.total.used", sum / BYTES_PER_KIB, "KiB", AggregationPolicy.MAX)); return results; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java000066400000000000000000000205741446271450100266430ustar00rootroot00000000000000/* * Copyright (c) 2016, 2020, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; import org.openjdk.jmh.runner.options.IntegerValueConverter; import org.openjdk.jmh.util.SampleBuffer; import org.openjdk.jmh.util.Statistics; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.LockSupport; public class PausesProfiler implements InternalProfiler { private Ticker ticker; private SampleBuffer buffer; private long expectedNs; private long thresh; @Override public String getDescription() { return "Pauses profiler"; } public PausesProfiler(String initLine) throws ProfilerException { OptionParser parser = new OptionParser(); parser.formatHelpWith(new ProfilerOptionFormatter(PausesProfiler.class.getCanonicalName())); OptionSpec optSamplePeriod = parser.accepts("period", "Sampling period, in us. " + "Smaller values improve accuracy, at the expense of more profiling overhead.") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int").defaultsTo(50); OptionSpec optThreshold = parser.accepts("threshold", "Threshold to filter pauses, in us. " + "If unset, the threshold is figured during the initial calibration.") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int").defaultsTo(-1); OptionSet set = ProfilerUtils.parseInitLine(initLine, parser); try { expectedNs = TimeUnit.MICROSECONDS.toNanos(set.valueOf(optSamplePeriod)); if (set.valueOf(optThreshold) != -1) { thresh = TimeUnit.MICROSECONDS.toNanos(set.valueOf(optThreshold)); } else { thresh = calibrate(); } } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } } @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { buffer = new SampleBuffer(); ticker = new Ticker(buffer); ticker.start(); } @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { ticker.interrupt(); try { ticker.join(); } catch (InterruptedException e) { // do nothing, proceed } return Collections.singletonList(new PausesProfilerResult(buffer)); } private long calibrate() { SampleBuffer buf = new SampleBuffer(); int cnt = 0; long startTime = System.nanoTime(); long lastTime = startTime; long limit = TimeUnit.SECONDS.toNanos(3); while ((cnt++ < 10_000) && (lastTime - startTime < limit)) { LockSupport.parkNanos(expectedNs); long time = System.nanoTime(); long actualNs = time - lastTime; long delta = actualNs - expectedNs; if (delta > 0) { buf.add(delta); } lastTime = time; } // The max observed pause during calibration must be our measurement // threshold. We cannot reliably guess the pauses lower than this are // caused by the benchmark pressure. Statistics stat = buf.getStatistics(1); return (long) stat.getMax(); } private class Ticker extends Thread { private final SampleBuffer buffer; public Ticker(SampleBuffer buffer) { this.buffer = buffer; setPriority(Thread.MAX_PRIORITY); setDaemon(true); } @Override public void run() { long lastTime = System.nanoTime(); while (!Thread.interrupted()) { LockSupport.parkNanos(expectedNs); long time = System.nanoTime(); long actualNs = time - lastTime; long delta = actualNs - expectedNs; if (delta > thresh) { // assume the actual pause starts within the sleep interval, // we can adjust the measurement by a half the expected time buffer.add(delta + expectedNs/2); } lastTime = time; } } } static class PausesProfilerResult extends Result { private static final long serialVersionUID = 3806848321463539969L; private final SampleBuffer buffer; public PausesProfilerResult(SampleBuffer buffer) { super(ResultRole.SECONDARY, "pauses", buffer.getStatistics(1D / 1_000_000), "ms", AggregationPolicy.SUM); this.buffer = buffer; } @Override protected Aggregator getThreadAggregator() { return new JoiningAggregator(); } @Override protected Aggregator getIterationAggregator() { return new JoiningAggregator(); } @Override protected Collection getDerivativeResults() { return Arrays.asList( new ScalarDerivativeResult("pauses.avg", statistics.getMean(), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("pauses.count", statistics.getN(), "#", AggregationPolicy.SUM), new ScalarDerivativeResult("pauses.p0.00", statistics.getMin(), "ms", AggregationPolicy.MIN), new ScalarDerivativeResult("pauses.p0.50", statistics.getPercentile(50), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("pauses.p0.90", statistics.getPercentile(90), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("pauses.p0.95", statistics.getPercentile(95), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("pauses.p0.99", statistics.getPercentile(99), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("pauses.p0.999", statistics.getPercentile(99.9), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("pauses.p0.9999", statistics.getPercentile(99.99),"ms", AggregationPolicy.AVG), new ScalarDerivativeResult("pauses.p1.00", statistics.getMax(), "ms", AggregationPolicy.MAX) ); } /** * Always add up all the samples into final result. * This will allow aggregate result to achieve better accuracy. */ private static class JoiningAggregator implements Aggregator { @Override public PausesProfilerResult aggregate(Collection results) { SampleBuffer buffer = new SampleBuffer(); for (PausesProfilerResult r : results) { buffer.addAll(r.buffer); } return new PausesProfilerResult(buffer); } } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/PerfSupport.java000066400000000000000000000032241446271450100261620ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import java.util.Collection; class PerfSupport { static final String PERF_EXEC; static { String perf = System.getenv("JMH_PERF"); PERF_EXEC = (perf == null) ? "perf" : perf; } public static boolean containsUnsupported(Collection msgs, String event) { for (String m : msgs) { if (m.contains(event) && m.contains("")) { return true; } } return false; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/Profiler.java000066400000000000000000000050011446271450100254460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; /** * Root profiler interface. * *

Profiler classes are expected to provide either a non-arg constructor, * or a constructor accepting single String argument, as the option line. * The treatment of option line is unspecified, and can be handled in * profiler-specific way. Profiler constructors can throw * {@link org.openjdk.jmh.profile.ProfilerException} if profiler cannot * operate, either because of misconfiguration, or help message requested. * The message in {@link org.openjdk.jmh.profile.ProfilerException} should * clearly articulate the reason. * *

JMH will try to discover profiler implementations using the SPI mechanism. * Note: discoverable implementations must provide a no-arg constructor * for initial discovery; the instance created during discovery will be rejected. * If implementation would have a constructor accepting the String option line, * it would be preferred for subsequent instantiation over the no-arg constructor. * *

Profilers normally implement one of the subinterfaces.

* @see org.openjdk.jmh.profile.ExternalProfiler * @see org.openjdk.jmh.profile.InternalProfiler */ public interface Profiler { /** * Human-readable one-line description of the profiler. * @return description */ String getDescription(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerException.java000066400000000000000000000030661446271450100273360ustar00rootroot00000000000000/* * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; public class ProfilerException extends Exception { private static final long serialVersionUID = 1095296690895652155L; public ProfilerException(Exception e) { super(e); } public ProfilerException(String s) { super(s); } public ProfilerException(String s, Throwable e) { super(s, e); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java000066400000000000000000000166211446271450100270100ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.openjdk.jmh.runner.options.ProfilerConfig; import java.io.PrintStream; import java.lang.reflect.InvocationTargetException; import java.util.*; public class ProfilerFactory { public static Profiler getProfilerOrException(ProfilerConfig cfg) throws ProfilerException { try { return getProfiler(cfg); } catch (InvocationTargetException e) { if (e.getCause() instanceof ProfilerException) { throw (ProfilerException) e.getCause(); } throw new ProfilerException(e); } catch (ProfilerException e) { throw e; } catch (Exception e) { throw new ProfilerException(e); } } private static Profiler getProfilerOrNull(ProfilerConfig cfg) { try { return getProfiler(cfg); } catch (Exception e) { return null; } } private static Profiler getProfiler(ProfilerConfig cfg) throws Exception { String desc = cfg.getKlass(); // Try built-in profilers first Class builtIn = BUILT_IN.get(desc); if (builtIn != null) { return instantiate(cfg, builtIn); } // Try discovered profilers then Collection> profilers = getDiscoveredProfilers(); for (Class p : profilers) { if (p.getCanonicalName().equals(desc)) { return instantiate(cfg, p); } } // Try the direct hit Class klass = (Class) Class.forName(desc); return instantiate(cfg, klass); } private static Profiler instantiate(ProfilerConfig cfg, Class p) throws InstantiationException, IllegalAccessException, InvocationTargetException { try { return p.getConstructor(String.class).newInstance(cfg.getOpts()); } catch (NoSuchMethodException e) { // fallthrough } try { return p.getConstructor().newInstance(); } catch (NoSuchMethodException e) { // fallthrough } throw new IllegalStateException("Cannot instantiate profiler"); } public static List getSupportedExternal(Collection cfg) { List profilers = new ArrayList<>(); for (ProfilerConfig p : cfg) { Profiler prof = ProfilerFactory.getProfilerOrNull(p); if (prof instanceof ExternalProfiler) { profilers.add((ExternalProfiler) prof); } } return profilers; } public static List getSupportedInternal(Collection cfg) { List profilers = new ArrayList<>(); for (ProfilerConfig p : cfg) { Profiler prof = ProfilerFactory.getProfilerOrNull(p); if (prof instanceof InternalProfiler) { profilers.add((InternalProfiler) prof); } } return profilers; } public static void listProfilers(PrintStream out) { int maxLen = 0; for (String s : BUILT_IN.keySet()) { maxLen = Math.max(maxLen, s.length()); } for (Class s : ProfilerFactory.getDiscoveredProfilers()) { maxLen = Math.max(maxLen, s.getCanonicalName().length()); } maxLen += 2; StringBuilder supported = new StringBuilder(); StringBuilder unsupported = new StringBuilder(); for (String s : BUILT_IN.keySet()) { try { Profiler prof = getProfilerOrException(new ProfilerConfig(s, "")); supported.append(String.format("%" + maxLen + "s: %s %s\n", s, prof.getDescription(), "")); } catch (ProfilerException e) { unsupported.append(String.format("%" + maxLen + "s: %s %s\n", s, "", "")); unsupported.append(e.getMessage()); unsupported.append("\n"); } } for (Class s : ProfilerFactory.getDiscoveredProfilers()) { try { Profiler prof = getProfilerOrException(new ProfilerConfig(s.getCanonicalName(), "")); supported.append(String.format("%" + maxLen + "s: %s %s\n", s.getCanonicalName(), prof.getDescription(), "(discovered)")); } catch (ProfilerException e) { unsupported.append(String.format("%" + maxLen + "s: %s %s\n", s, s.getCanonicalName(), "")); unsupported.append(e.getMessage()); unsupported.append("\n"); } } if (!supported.toString().isEmpty()) { out.println("Supported profilers:\n" + supported.toString()); } if (!unsupported.toString().isEmpty()) { out.println("Unsupported profilers:\n" + unsupported.toString()); } } private static final Map> BUILT_IN; static { BUILT_IN = new TreeMap<>(); BUILT_IN.put("async", AsyncProfiler.class); BUILT_IN.put("cl", ClassloaderProfiler.class); BUILT_IN.put("comp", CompilerProfiler.class); BUILT_IN.put("gc", GCProfiler.class); BUILT_IN.put("jfr", JavaFlightRecorderProfiler.class); BUILT_IN.put("stack", StackProfiler.class); BUILT_IN.put("perf", LinuxPerfProfiler.class); BUILT_IN.put("perfnorm", LinuxPerfNormProfiler.class); BUILT_IN.put("perfasm", LinuxPerfAsmProfiler.class); BUILT_IN.put("mempool", MemPoolProfiler.class); BUILT_IN.put("xperfasm", WinPerfAsmProfiler.class); BUILT_IN.put("dtraceasm", DTraceAsmProfiler.class); BUILT_IN.put("pauses", PausesProfiler.class); BUILT_IN.put("safepoints", SafepointsProfiler.class); BUILT_IN.put("perfc2c", LinuxPerfC2CProfiler.class); } private static List> getDiscoveredProfilers() { List> profs = new ArrayList<>(); for (Profiler s : ServiceLoader.load(Profiler.class)) { profs.add(s.getClass()); } return profs; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerOptionFormatter.java000066400000000000000000000071071446271450100305340ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.HelpFormatter; import joptsimple.OptionDescriptor; import org.openjdk.jmh.util.Utils; import java.util.List; import java.util.Map; class ProfilerOptionFormatter implements HelpFormatter { private static final String LINE_SEPARATOR = System.getProperty("line.separator"); private final String name; public ProfilerOptionFormatter(String name) { this.name = name; } public String format(Map options) { StringBuilder sb = new StringBuilder(); sb.append("Usage: -prof :opt1=value1,value2;opt2=value3"); sb.append(LINE_SEPARATOR); sb.append(LINE_SEPARATOR); sb.append("Options accepted by ").append(name).append(":"); for (OptionDescriptor each : options.values()) { sb.append(lineFor(each)); } return sb.toString(); } private String lineFor(OptionDescriptor d) { StringBuilder line = new StringBuilder(); StringBuilder o = new StringBuilder(); o.append(" "); for (String str : d.options()) { if (d.representsNonOptions()) continue; o.append(str); if (d.acceptsArguments()) { o.append("="); if (d.requiresArgument()) { o.append("<"); } else { o.append("["); } o.append(d.argumentDescription()); if (d.requiresArgument()) { o.append(">"); } else { o.append("]"); } } } final int optWidth = 35; line.append(String.format("%-" + optWidth + "s", o.toString())); boolean first = true; String desc = d.description(); List defaults = d.defaultValues(); if (defaults != null && !defaults.isEmpty()) { desc += " (default: " + defaults.toString() + ")"; } for (String l : Utils.rewrap(desc)) { if (first) { first = false; } else { line.append(LINE_SEPARATOR); line.append(String.format("%-" + optWidth + "s", "")); } line.append(l); } line.append(LINE_SEPARATOR); line.append(LINE_SEPARATOR); return line.toString(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java000066400000000000000000000100271446271450100264730ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.BenchmarkResultMetaData; import java.io.IOException; import java.io.StringWriter; import java.util.concurrent.TimeUnit; class ProfilerUtils { public static OptionSet parseInitLine(String initLine, OptionParser parser) throws ProfilerException { parser.accepts("help", "Display help."); OptionSpec nonOptions = parser.nonOptions(); String[] split = initLine.split(";"); for (int c = 0; c < split.length; c++) { if (!split[c].isEmpty()) { split[c] = "-" + split[c]; } } OptionSet set; try { set = parser.parse(split); } catch (OptionException e) { try { StringWriter sw = new StringWriter(); sw.append(e.getMessage()); sw.append("\n"); parser.printHelpOn(sw); throw new ProfilerException(sw.toString()); } catch (IOException e1) { throw new ProfilerException(e1); } } if (set.has("help")) { try { StringWriter sw = new StringWriter(); parser.printHelpOn(sw); throw new ProfilerException(sw.toString()); } catch (IOException e) { e.printStackTrace(); } } String s = set.valueOf(nonOptions); if (s != null && !s.isEmpty()) { throw new ProfilerException("Unhandled options: " + s + " in " + initLine); } return set; } public static long measurementDelayMs(BenchmarkResult br) { BenchmarkResultMetaData md = br.getMetadata(); if (md != null) { // try to ask harness itself: return md.getMeasurementTime() - md.getStartTime(); } else { // metadata is not available, let's make a guess: IterationParams wp = br.getParams().getWarmup(); return wp.getCount() * wp.getTime().convertTo(TimeUnit.MILLISECONDS) + TimeUnit.SECONDS.toMillis(1); // loosely account for the JVM lag } } public static long measuredTimeMs(BenchmarkResult br) { BenchmarkResultMetaData md = br.getMetadata(); if (md != null) { // try to ask harness itself: return md.getStopTime() - md.getMeasurementTime(); } else { // metadata is not available, let's make a guess: IterationParams mp = br.getParams().getMeasurement(); return mp.getCount() * mp.getTime().convertTo(TimeUnit.MILLISECONDS); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java000066400000000000000000000253551446271450100275200ustar00rootroot00000000000000/* * Copyright (c) 2016, 2020, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.*; import org.openjdk.jmh.util.SampleBuffer; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SafepointsProfiler implements ExternalProfiler { private static final long NO_LONG_VALUE = Long.MIN_VALUE; @Override public String getDescription() { return "Safepoints profiler"; } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { return Collections.emptyList(); } @Override public Collection addJVMOptions(BenchmarkParams params) { return Arrays.asList( // make sure old JVMs don't barf on Unified Logging "-XX:+IgnoreUnrecognizedVMOptions", // JDK 9+: preferred, Unified Logging "-Xlog:safepoint=info", // pre JDK-9: special options "-XX:+PrintGCApplicationStoppedTime", "-XX:+PrintGCTimeStamps" ); } @Override public void beforeTrial(BenchmarkParams benchmarkParams) { // do nothing } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { long measuredTimeMs = ProfilerUtils.measuredTimeMs(br); long measuredTimeNs = TimeUnit.MILLISECONDS.toNanos(measuredTimeMs); long measureFrom = TimeUnit.MILLISECONDS.toNanos(ProfilerUtils.measurementDelayMs(br)); long measureTo = measureFrom + measuredTimeNs; List ds = new ArrayList<>(); try (BufferedReader reader = Files.newBufferedReader(stdOut.toPath(), Charset.defaultCharset())) { String line; while ((line = reader.readLine()) != null) { ParsedData data = parse(line); if (data != null) { ds.add(data); } } } catch (IOException e) { throw new IllegalStateException(e); } // Only accept the lines from the highest version. long maxVer = Long.MIN_VALUE; for (ParsedData d : ds) { maxVer = Math.max(maxVer, d.ver); } SampleBuffer pauseBuff = new SampleBuffer(); SampleBuffer ttspBuff = new SampleBuffer(); for (ParsedData d : ds) { if (d.ver == maxVer && (d.timestamp > measureFrom) && (d.timestamp < measureTo)) { pauseBuff.add(d.stopTime); if (d.ttspTime != NO_LONG_VALUE) { ttspBuff.add(d.ttspTime); } } } Collection results = new ArrayList<>(); results.add(new ScalarResult("safepoints.interval", measuredTimeMs, "ms", AggregationPolicy.SUM)); results.add(new SafepointProfilerResult("pause", pauseBuff)); // JDK 7 does not have TTSP measurements, ignore the zero metric: if (maxVer > 7) { results.add(new SafepointProfilerResult("ttsp", ttspBuff)); } return results; } static long parseNs(String str) { return (long) (Double.parseDouble(str.replace(',', '.'))); } static long parseSecToNs(String str) { return (long) (Double.parseDouble(str.replace(',', '.')) * TimeUnit.SECONDS.toNanos(1)); } @Override public boolean allowPrintOut() { return false; } @Override public boolean allowPrintErr() { return true; } static class SafepointProfilerResult extends Result { private static final long serialVersionUID = -88756998141554941L; private final String suffix; private final SampleBuffer buffer; public SafepointProfilerResult(String suffix, SampleBuffer buffer) { super(ResultRole.SECONDARY, "safepoints." + suffix, buffer.getStatistics(1D / 1_000_000), "ms", AggregationPolicy.SUM); this.suffix = suffix; this.buffer = buffer; } @Override protected Aggregator getThreadAggregator() { return new JoiningAggregator(); } @Override protected Aggregator getIterationAggregator() { return new JoiningAggregator(); } @Override protected Collection getDerivativeResults() { return Arrays.asList( new ScalarDerivativeResult("safepoints." + suffix + ".avg", statistics.getMean(), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("safepoints." + suffix + ".count", statistics.getN(), "#", AggregationPolicy.SUM), new ScalarDerivativeResult("safepoints." + suffix + ".p0.00", statistics.getMin(), "ms", AggregationPolicy.MIN), new ScalarDerivativeResult("safepoints." + suffix + ".p0.50", statistics.getPercentile(50), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("safepoints." + suffix + ".p0.90", statistics.getPercentile(90), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("safepoints." + suffix + ".p0.95", statistics.getPercentile(95), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("safepoints." + suffix + ".p0.99", statistics.getPercentile(99), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("safepoints." + suffix + ".p0.999", statistics.getPercentile(99.9), "ms", AggregationPolicy.AVG), new ScalarDerivativeResult("safepoints." + suffix + ".p0.9999", statistics.getPercentile(99.99),"ms", AggregationPolicy.AVG), new ScalarDerivativeResult("safepoints." + suffix + ".p1.00", statistics.getMax(), "ms", AggregationPolicy.MAX) ); } /** * Always add up all the samples into final result. * This will allow aggregate result to achieve better accuracy. */ private static class JoiningAggregator implements Aggregator { @Override public SafepointProfilerResult aggregate(Collection results) { SampleBuffer buffer = new SampleBuffer(); String suffix = null; for (SafepointProfilerResult r : results) { buffer.addAll(r.buffer); if (suffix == null) { suffix = r.suffix; } else if (!suffix.equals(r.suffix)) { throw new IllegalStateException("Trying to aggregate results with different suffixes"); } } return new SafepointProfilerResult(suffix, buffer); } } } private static final Pattern JDK_7_LINE = Pattern.compile("([0-9\\.,]*): (.*) stopped: ([0-9\\.,]*) seconds"); private static final Pattern JDK_8_LINE = Pattern.compile("([0-9\\.,]*): (.*) stopped: ([0-9\\.,]*) seconds, (.*) took: ([0-9\\.,]*) seconds"); private static final Pattern JDK_9_LINE = Pattern.compile("\\[([0-9\\.,]*)s\\]\\[info\\]\\[safepoint( *)\\] (.*) stopped: ([0-9\\.,]*) seconds, (.*) took: ([0-9\\.,]*) seconds"); private static final Pattern JDK_13_LINE = Pattern.compile("\\[([0-9\\.,]*)s\\]\\[info\\]\\[safepoint( *)\\] (.*) Reaching safepoint: ([0-9\\.,]*) ns, (.*) Total: ([0-9\\.,]*) ns"); /** * Parse the line into the triplet. This is tested with unit tests, make sure to * update those if changing this code. */ static ParsedData parse(String line) { { Matcher m = JDK_7_LINE.matcher(line); if (m.matches()) { return new ParsedData( 7, parseSecToNs(m.group(1)), parseSecToNs(m.group(3)), NO_LONG_VALUE ); } } { Matcher m = JDK_8_LINE.matcher(line); if (m.matches()) { return new ParsedData( 8, parseSecToNs(m.group(1)), parseSecToNs(m.group(3)), parseSecToNs(m.group(5)) ); } } { Matcher m = JDK_9_LINE.matcher(line); if (m.matches()) { return new ParsedData( 9, parseSecToNs(m.group(1)), parseSecToNs(m.group(4)), parseSecToNs(m.group(6)) ); } } { Matcher m = JDK_13_LINE.matcher(line); if (m.matches()) { return new ParsedData( 13, parseSecToNs(m.group(1)), parseNs(m.group(6)), parseNs(m.group(4)) ); } } return null; } static class ParsedData { int ver; long timestamp; long stopTime; long ttspTime; public ParsedData(int ver, long timestamp, long stopTime, long ttspTime) { this.ver = ver; this.timestamp = timestamp; this.stopTime = stopTime; this.ttspTime = ttspTime; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java000066400000000000000000000366331446271450100264530ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; import org.openjdk.jmh.runner.options.IntegerValueConverter; import org.openjdk.jmh.util.HashMultiset; import org.openjdk.jmh.util.Multiset; import org.openjdk.jmh.util.Multisets; import java.io.Serializable; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.util.*; import java.util.concurrent.TimeUnit; /** * Very basic and naive stack profiler. */ public class StackProfiler implements InternalProfiler { /** * Threads to ignore (known system and harness threads) */ private static final String[] IGNORED_THREADS = { "Finalizer", "Signal Dispatcher", "Reference Handler", "main", "Sampling Thread", "Attach Listener" }; private final int stackLines; private final int topStacks; private final int periodMsec; private final boolean sampleLine; private final Set excludePackageNames; public StackProfiler(String initLine) throws ProfilerException { OptionParser parser = new OptionParser(); parser.formatHelpWith(new ProfilerOptionFormatter(StackProfiler.class.getCanonicalName())); OptionSpec optStackLines = parser.accepts("lines", "Number of stack lines to save in each stack trace. " + "Larger values provide more insight into who is calling the top stack method, as the expense " + "of more stack trace shapes to collect.") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int").defaultsTo(1); OptionSpec optTopStacks = parser.accepts("top", "Number of top stacks to show in the profiling results. " + "Larger values may catch some stack traces that linger in the distribution tail.") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int").defaultsTo(10); OptionSpec optSamplePeriod = parser.accepts("period", "Sampling period, in milliseconds. " + "Smaller values improve accuracy, at the expense of more profiling overhead.") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int").defaultsTo(10); OptionSpec optDetailLine = parser.accepts("detailLine", "Record detailed source line info. " + "This adds the line numbers to the recorded stack traces.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSpec optExclude = parser.accepts("excludePackages", "Enable package filtering. " + "Use excludePackages option to control what packages are filtered") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); OptionSpec optExcludeClasses = parser.accepts("excludePackageNames", "Filter there packages. " + "This is expected to be a comma-separated list\n" + "of the fully qualified package names to be excluded. Every stack line that starts with the provided\n" + "patterns will be excluded.") .withRequiredArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("package+") .defaultsTo("java.", "javax.", "sun.", "sunw.", "com.sun.", "org.openjdk.jmh."); OptionSet set = ProfilerUtils.parseInitLine(initLine, parser); try { sampleLine = set.valueOf(optDetailLine); periodMsec = set.valueOf(optSamplePeriod); topStacks = set.valueOf(optTopStacks); stackLines = set.valueOf(optStackLines); boolean excludePackages = set.valueOf(optExclude); excludePackageNames = excludePackages ? new HashSet<>(set.valuesOf(optExcludeClasses)) : Collections.emptySet(); } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } } private volatile SamplingTask samplingTask; @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { samplingTask = new SamplingTask(); samplingTask.start(); } @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { samplingTask.stop(); return Collections.singleton(new StackResult(samplingTask.stacks, topStacks)); } @Override public String getDescription() { return "Simple and naive Java stack profiler"; } public class SamplingTask implements Runnable { private final Thread thread; private final Map> stacks; public SamplingTask() { stacks = new EnumMap<>(Thread.State.class); for (Thread.State s : Thread.State.values()) { stacks.put(s, new HashMultiset<>()); } thread = new Thread(this); thread.setName("Sampling Thread"); } @Override public void run() { while (!Thread.interrupted()) { ThreadInfo[] infos = ManagementFactory.getThreadMXBean().dumpAllThreads(false, false); info: for (ThreadInfo info : infos) { // filter out ignored threads for (String ignore : IGNORED_THREADS) { if (info.getThreadName().equalsIgnoreCase(ignore)) { continue info; } } // - Discard everything that matches excluded patterns from the top of the stack // - Get the remaining number of stack lines and build the stack record StackTraceElement[] stack = info.getStackTrace(); List lines = new ArrayList<>(); for (StackTraceElement l : stack) { String className = l.getClassName(); if (!isExcluded(className)) { lines.add(className + '.' + l.getMethodName() + (sampleLine ? ":" + l.getLineNumber() : "")); if (lines.size() >= stackLines) { break; } } } if (lines.isEmpty()) { lines.add(""); } Thread.State state = info.getThreadState(); stacks.get(state).add(new StackRecord(lines)); } try { TimeUnit.MILLISECONDS.sleep(periodMsec); } catch (InterruptedException e) { return; } } } public void start() { thread.start(); } public void stop() { thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } private boolean isExcluded(String className) { for (String p : excludePackageNames) { if (className.startsWith(p)) { return true; } } return false; } } private static class StackRecord implements Serializable { private static final long serialVersionUID = -1829626661894754733L; public final List lines; private StackRecord(List lines) { this.lines = lines; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StackRecord that = (StackRecord) o; return lines.equals(that.lines); } @Override public int hashCode() { return lines.hashCode(); } } public static class StackResult extends Result { private static final long serialVersionUID = 2609170863630346073L; private final Map> stacks; private final int topStacks; public StackResult(Map> stacks, int topStacks) { super(ResultRole.SECONDARY, "stack", of(Double.NaN), "---", AggregationPolicy.AVG); this.stacks = stacks; this.topStacks = topStacks; } @Override protected Aggregator getThreadAggregator() { return new StackResultAggregator(); } @Override protected Aggregator getIterationAggregator() { return new StackResultAggregator(); } @Override public String toString() { return ""; } @Override public String extendedInfo() { return getStack(stacks); } public String getStack(final Map> stacks) { List sortedStates = new ArrayList<>(stacks.keySet()); sortedStates.sort(new Comparator() { private long stateSize(Thread.State state) { Multiset set = stacks.get(state); return (set == null) ? 0 : set.size(); } @Override public int compare(Thread.State s1, Thread.State s2) { return Long.compare(stateSize(s2), stateSize(s1)); } }); long totalSize = getTotalSize(stacks); StringBuilder builder = new StringBuilder(); builder.append("Stack profiler:\n\n"); builder.append(dottedLine("Thread state distributions")); for (Thread.State state : sortedStates) { if (isSignificant(stacks.get(state).size(), totalSize)) { builder.append(String.format("%5.1f%% %7s %s%n", stacks.get(state).size() * 100.0 / totalSize, "", state)); } } builder.append("\n"); for (Thread.State state : sortedStates) { Multiset stateStacks = stacks.get(state); if (isSignificant(stateStacks.size(), totalSize)) { builder.append(dottedLine("Thread state: " + state.toString())); int totalDisplayed = 0; for (StackRecord s : Multisets.countHighest(stateStacks, topStacks)) { List lines = s.lines; if (!lines.isEmpty()) { totalDisplayed += stateStacks.count(s); builder.append(String.format("%5.1f%% %5.1f%% %s%n", stateStacks.count(s) * 100.0 / totalSize, stateStacks.count(s) * 100.0 / stateStacks.size(), lines.get(0))); if (lines.size() > 1) { for (int i = 1; i < lines.size(); i++) { builder.append(String.format("%13s %s%n", "", lines.get(i))); } builder.append("\n"); } } } if (isSignificant((stateStacks.size() - totalDisplayed), stateStacks.size())) { builder.append(String.format("%5.1f%% %5.1f%% %s%n", (stateStacks.size() - totalDisplayed) * 100.0 / totalSize, (stateStacks.size() - totalDisplayed) * 100.0 / stateStacks.size(), "")); } builder.append("\n"); } } return builder.toString(); } // returns true, if part is >0.1% of total private boolean isSignificant(long part, long total) { // returns true if part*100.0/total is greater or equals to 0.1 return part * 1000 >= total; } private long getTotalSize(Map> stacks) { long sum = 0; for (Multiset set : stacks.values()) { sum += set.size(); } return sum; } } static String dottedLine(String header) { final int HEADER_WIDTH = 100; StringBuilder sb = new StringBuilder(); sb.append("...."); if (header != null) { header = "[" + header + "]"; sb.append(header); } else { header = ""; } for (int c = 0; c < HEADER_WIDTH - 4 - header.length(); c++) { sb.append("."); } sb.append("\n"); return sb.toString(); } public static class StackResultAggregator implements Aggregator { @Override public StackResult aggregate(Collection results) { int topStacks = 0; Map> sum = new EnumMap<>(Thread.State.class); for (StackResult r : results) { for (Map.Entry> entry : r.stacks.entrySet()) { if (!sum.containsKey(entry.getKey())) { sum.put(entry.getKey(), new HashMultiset<>()); } Multiset sumSet = sum.get(entry.getKey()); for (StackRecord rec : entry.getValue().keys()) { sumSet.add(rec, entry.getValue().count(rec)); } } topStacks = r.topStacks; } return new StackResult(sum, topStacks); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java000066400000000000000000000274021446271450100274130ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.util.*; import java.io.*; import java.util.*; /** * Windows performance profiler based on "xperf" utility. *

* You must install {@code Windows Performance Toolkit}. Once installed, locate directory with {@code xperf.exe} * file and either add it to {@code PATH} environment variable, or assign it to {@code xperf.dir} parameter. *

* This profiler counts only {@code SampledProfile} events. To achieve this, we set {@code xperf} providers to * {@code loader+proc_thread+profile}. You may optionally save {@code xperf} binary or parsed outputs using * {@code savePerfBin} or {@code savePerf} parameters respectively. If you do so and * want to log more events, you can use {@code xperf.providers} parameter to override providers. * However, you must specify {@code loader}, {@code proc_thread} and {@code profile} providers anyway. Otherwise * sample events will not be generated and profiler will show nothing. *

* By default JDK distributive do not have debug symbols. If you want to analyze JVM internals, you must build OpenJDK * on your own. Once built, go to {@code bin/server} directory and unpack {@code jvm.diz}. Now you have {@code jvm.pdb} * file with JVM debug symbols. Finally, you must assign debug symbols directory to {@code symbol.dir} parameter. *

* This profiler behaves differently comparing to it's Linux counterpart {@link LinuxPerfAsmProfiler}. Linux profiler * employs {@code perf} utility which can be used to profile a single process. Therefore, Linux profiler wraps forked * JVM command line. In contrast, {@code xperf} cannot profile only a single process. It have {@code -PidNewProcess} * argument, but it's sole purpose is to start profiling before the process is started, so that one can be sure that * none events generated by this process are missed. It does not filter events from other processes anyhow. For this * reason, this profiler doesn't alter forked JVM startup command. Instead, it starts {@code xperf} recording in * {@link #beforeTrial(BenchmarkParams)} method, and stops in {@link ExternalProfiler#afterTrial(org.openjdk.jmh.results.BenchmarkResult, long, java.io.File, java.io.File)}. This * leaves possibility to run this profiler in conjunction with some other profiler requiring startup command * alteration. *

* For this reason the profiler must know PID of forked JVM process. */ public class WinPerfAsmProfiler extends AbstractPerfAsmProfiler { private static final String MSG_UNABLE_START = "Unable to start the profiler. Try running JMH as Administrator, " + "and ensure that previous profiling session is stopped. Use 'xperf -stop' to stop the active profiling session."; private static final String MSG_UNABLE_STOP = "Unable to stop the profiler. Please try running JMH as Administrator."; private final String xperfProviders; private final String symbolDir; private final String path; /** PID. */ private volatile String pid; private OptionSpec optXperfDir; private OptionSpec optXperfProviders; private OptionSpec optSymbolDir; public WinPerfAsmProfiler(String initLine) throws ProfilerException { super(initLine, "SampledProfile"); try { String xperfDir = set.valueOf(optXperfDir); xperfProviders = set.valueOf(optXperfProviders); symbolDir = set.valueOf(optSymbolDir); path = xperfDir != null && !xperfDir.isEmpty() ? xperfDir + File.separatorChar + "xperf" : "xperf"; } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } Collection errsOn = Utils.tryWith(path, "-on", xperfProviders); if (!errsOn.isEmpty()) { throw new ProfilerException(MSG_UNABLE_START + ": " + errsOn); } Collection errsStop = Utils.tryWith(path, "-stop"); if (!errsStop.isEmpty()) { throw new ProfilerException(MSG_UNABLE_STOP + ": " + errsStop); } } @Override protected void addMyOptions(OptionParser parser) { optXperfDir = parser.accepts("xperf.dir", "Path to \"xperf\" installation directory. Empty by default, so that xperf is expected to be in PATH.") .withRequiredArg().ofType(String.class).describedAs("path"); optXperfProviders = parser.accepts("xperf.providers", "xperf providers to use.") .withRequiredArg().ofType(String.class).describedAs("string").defaultsTo("loader+proc_thread+profile"); optSymbolDir = parser.accepts("symbol.dir", "Path to a directory with jvm.dll symbols (optional).") .withRequiredArg().ofType(String.class).describedAs("string"); } @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { // "xperf" cannot be started to track particular process as "perf" in Linux does. // Therefore we do not alter JVM invoke options anyhow. Instead, profiler will be started // during "before-trial" stage. return Collections.emptyList(); } @Override public void beforeTrial(BenchmarkParams params) { // Start profiler before forked JVM is started. Collection errs = Utils.tryWith(path, "-on", xperfProviders); if (!errs.isEmpty()) { throw new IllegalStateException(MSG_UNABLE_START + ": " + errs); } } @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { if (pid == 0) { throw new IllegalStateException("perfasm needs the forked VM PID, but it is not initialized."); } this.pid = String.valueOf(pid); return super.afterTrial(br, pid, stdOut, stdErr); } @Override public String getDescription() { return "Windows xperf + PrintAssembly Profiler"; } @Override protected void parseEvents() { // 1. Stop profiling by calling xperf dumper. Collection errs = Utils.tryWith(path, "-d", perfBinData.getAbsolutePath()); if (!errs.isEmpty()) { throw new IllegalStateException(MSG_UNABLE_STOP + ": " + errs); } // 2. Convert binary data to text form. try { ProcessBuilder pb = new ProcessBuilder(path, "-i", perfBinData.getAbsolutePath(), "-symbols", "-a", "dumper"); if (symbolDir != null) { pb.environment().put("_NT_SYMBOL_PATH", symbolDir); } Process p = pb.start(); FileOutputStream fos = new FileOutputStream(perfParsedData.file()); InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), fos); InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), fos); errDrainer.start(); outDrainer.start(); p.waitFor(); errDrainer.join(); outDrainer.join(); } catch (IOException | InterruptedException ex) { throw new IllegalStateException(ex); } } @Override protected PerfEvents readEvents(double skipMs, double lenMs) { double readFrom = skipMs / 1000D; double readTo = (skipMs + lenMs) / 1000D; try (FileReader fr = new FileReader(perfParsedData.file()); BufferedReader reader = new BufferedReader(fr)) { Deduplicator dedup = new Deduplicator<>(); Multimap methods = new HashMultimap<>(); Map> events = new LinkedHashMap<>(); for (String evName : requestedEventNames) { events.put(evName, new TreeMultiset<>()); } String line; while ((line = reader.readLine()) != null) { line = line.trim(); String[] elems = line.split(",\\s+"); String evName = elems[0].trim(); // We work with only one event type - "SampledProfile". if (!requestedEventNames.get(0).equals(evName)) continue; // Check PID. String pidStr = elems[2].trim(); int pidOpenIdx = pidStr.indexOf("("); int pidCloseIdx = pidStr.indexOf(")"); if (pidOpenIdx == -1 || pidCloseIdx == -1 || pidCloseIdx < pidOpenIdx) continue; // Malformed PID, probably this is the header. pidStr = pidStr.substring(pidOpenIdx + 1, pidCloseIdx).trim(); if (!pid.equals(pidStr)) continue; // Check timestamp String timeStr = elems[1].trim(); double time = Double.parseDouble(timeStr) / 1_000_000; if (time < readFrom) continue; if (time > readTo) continue; // Get address. String addrStr = elems[4].trim().replace("0x", ""); // Get lib and function name. String libSymStr = elems[7].trim(); String lib = libSymStr.substring(0, libSymStr.indexOf('!')); String symbol = libSymStr.substring(libSymStr.indexOf('!') + 1); Multiset evs = events.get(evName); assert evs != null; try { Long addr = Long.parseLong(addrStr, 16); evs.add(addr); methods.put(dedup.dedup(MethodDesc.nativeMethod(symbol, lib)), addr); } catch (NumberFormatException e) { // kernel addresses like "ffffffff810c1b00" overflow signed long, // record them as dummy address evs.add(0L); } } IntervalMap methodMap = new IntervalMap<>(); for (MethodDesc md : methods.keys()) { Collection longs = methods.get(md); methodMap.add(md, Utils.min(longs), Utils.max(longs)); } return new PerfEvents(requestedEventNames, events, methodMap); } catch (IOException e) { throw new RuntimeException(e); } } @Override protected String perfBinaryExtension() { // Files with ".etl" extension can be opened by "Windows Performance Analyzer" right away. return ".etl"; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/000077500000000000000000000000001446271450100230665ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/AggregationPolicy.java000066400000000000000000000027771446271450100273550ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; public enum AggregationPolicy { AVG("Average"), SUM("Sum"), MAX("Maximum"), MIN("Minimum"), ; private final String label; AggregationPolicy(String label) { this.label = label; } public String toString() { return label; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/Aggregator.java000066400000000000000000000033551446271450100260210ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import java.util.Collection; /** * Aggregator composes multiple results into one. * * It is assumed the collection has the results of specified type. * This class is generic to save some of the unchecked casts in the code. * * @param accepted result type */ public interface Aggregator { /** * Aggregate the results. * @param results results to aggregate * @return aggregated result; may throw exceptions on validation errors */ R aggregate(Collection results); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/AggregatorUtils.java000066400000000000000000000057521446271450100270450ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import java.util.Collection; public final class AggregatorUtils { private AggregatorUtils() { // prevent instantation } static ResultRole aggregateRoles(Collection results) { ResultRole result = null; for (Result r : results) { if (result == null) { result = r.role; } else if (result != r.role) { throw new IllegalStateException("Combining the results with different roles"); } } return result; } static String aggregateUnits(Collection results) { String result = null; for (Result r : results) { if (result == null) { result = r.unit; } else if (!result.equals(r.unit)) { throw new IllegalStateException("Combining the results with different units"); } } return result; } static String aggregateLabels(Collection results) { String result = null; for (Result r : results) { if (result == null) { result = r.label; } else if (!result.equals(r.label)) { throw new IllegalStateException("Combining the results with different labels"); } } return result; } static AggregationPolicy aggregatePolicies(Collection results) { AggregationPolicy result = null; for (Result r : results) { if (result == null) { result = r.policy; } else if (!result.equals(r.policy)) { throw new IllegalStateException("Combining the results with different aggregation policies"); } } return result; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/AverageTimeResult.java000066400000000000000000000056351446271450100273320ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.ListStatistics; import org.openjdk.jmh.util.Statistics; import java.util.Collection; import java.util.concurrent.TimeUnit; /** * Result class that stores average operation time. */ public class AverageTimeResult extends Result { private static final long serialVersionUID = 6937689337229703312L; public AverageTimeResult(ResultRole mode, String label, double operations, long durationNs, TimeUnit tu) { this(mode, label, of(durationNs / (operations * TimeUnit.NANOSECONDS.convert(1, tu))), TimeValue.tuToString(tu) + "/op"); } AverageTimeResult(ResultRole mode, String label, Statistics value, String unit) { super(mode, label, value, unit, AggregationPolicy.AVG); } @Override protected Aggregator getThreadAggregator() { return new ResultAggregator(); } @Override protected Aggregator getIterationAggregator() { return new ResultAggregator(); } static class ResultAggregator implements Aggregator { @Override public AverageTimeResult aggregate(Collection results) { ListStatistics stat = new ListStatistics(); for (AverageTimeResult r : results) { stat.addValue(r.getScore()); } return new AverageTimeResult( AggregatorUtils.aggregateRoles(results), AggregatorUtils.aggregateLabels(results), stat, AggregatorUtils.aggregateUnits(results) ); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResult.java000066400000000000000000000151661446271450100270330ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import java.io.Serializable; import java.util.*; /** * Benchmark result. * Contains iteration results. */ public class BenchmarkResult implements Serializable { private static final long serialVersionUID = 6467912427356048369L; private final Collection iterationResults; private final Multimap benchmarkResults; private final BenchmarkParams params; private final BenchmarkResultMetaData metadata; public BenchmarkResult(BenchmarkParams params, Collection data) { this(params, data, null); } public BenchmarkResult(BenchmarkParams params, Collection data, BenchmarkResultMetaData md) { this.metadata = md; this.benchmarkResults = new HashMultimap<>(); this.iterationResults = data; this.params = params; } /** * @return returns the benchmark metadata, "null" otherwise */ public BenchmarkResultMetaData getMetadata() { return metadata; } public void addBenchmarkResult(Result r) { benchmarkResults.put(r.getLabel(), r); } public Collection getIterationResults() { return iterationResults; } public Multimap getBenchmarkResults() { return benchmarkResults; } public Result getPrimaryResult() { Aggregator aggregator = null; Collection aggrs = new ArrayList<>(); for (IterationResult r : iterationResults) { Result e = r.getPrimaryResult(); aggrs.add(e); aggregator = e.getIterationAggregator(); } for (Result r : benchmarkResults.values()) { if (r.getRole().isPrimary()) { aggrs.add(r); } } if (aggregator != null) { return aggregator.aggregate(aggrs); } else { throw new IllegalStateException("No aggregator for primary result"); } } public Map getSecondaryResults() { // label -> collection of results Multimap allSecondary = new HashMultimap<>(); // Build multiset of all results to capture if some labels are missing in some of the iterations for (IterationResult ir : iterationResults) { Map secondaryResults = ir.getSecondaryResults(); for (Map.Entry entry : secondaryResults.entrySet()) { // skip derivatives from aggregation here if (entry.getValue().getRole().isDerivative()) continue; allSecondary.put(entry.getKey(), entry.getValue()); } } Map answers = new TreeMap<>(); int totalIterations = iterationResults.size(); // Create "0" entries in case certain labels did not appear in some of the iterations for (String label : allSecondary.keys()) { Collection results = allSecondary.get(label); Result firstResult = results.iterator().next(); Result emptyResult = firstResult.getZeroResult(); if (emptyResult != null) { for (int i = results.size(); i < totalIterations; i++) { allSecondary.put(label, emptyResult); } } @SuppressWarnings("unchecked") Aggregator aggregator = firstResult.getIterationAggregator(); if (aggregator == null) { if (results.size() == 1) { answers.put(label, firstResult); continue; } throw new IllegalStateException("No aggregator for " + firstResult); } // Note: should not use "results" here since the contents was just updated by "put" above Result aggregate = aggregator.aggregate(allSecondary.get(label)); answers.put(label, aggregate); } for (String label : benchmarkResults.keys()) { Aggregator aggregator = null; Collection results = new ArrayList<>(); for (Result r : benchmarkResults.get(label)) { if (r.getRole().isSecondary() && !r.getRole().isDerivative()) { results.add(r); aggregator = r.getIterationAggregator(); } } if (aggregator != null) { answers.put(label, aggregator.aggregate(results)); } } // put all secondary derivative results on top: from primaries answers.putAll(produceDerivative(getPrimaryResult())); // add all derivative results on top: from secondaries Map adds = new HashMap<>(); for (Result r : answers.values()) { adds.putAll(produceDerivative(r)); } answers.putAll(adds); return answers; } private Map produceDerivative(Result r) { Map map = new HashMap<>(); for (Object rr : r.getDerivativeResults()) { map.put(((Result) rr).getLabel(), (Result) rr); } return map; } public String getScoreUnit() { return getPrimaryResult().getScoreUnit(); } public BenchmarkParams getParams() { return params; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResultMetaData.java000066400000000000000000000051041446271450100304230ustar00rootroot00000000000000/* * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import java.io.Serializable; public class BenchmarkResultMetaData implements Serializable { private static final long serialVersionUID = -2512961914593247551L; private long startTime; private final long warmupTime; private final long measurementTime; private final long stopTime; private final long warmupOps; private final long measurementOps; public BenchmarkResultMetaData(long warmupTime, long measurementTime, long stopTime, long warmupOps, long measurementOps) { this.startTime = Long.MIN_VALUE; this.warmupTime = warmupTime; this.measurementTime = measurementTime; this.stopTime = stopTime; this.warmupOps = warmupOps; this.measurementOps = measurementOps; } public long getStartTime() { if (startTime == Long.MIN_VALUE) { throw new IllegalStateException("Unset start time"); } return startTime; } public long getWarmupTime() { return warmupTime; } public long getMeasurementTime() { return measurementTime; } public long getStopTime() { return stopTime; } public long getMeasurementOps() { return measurementOps; } public long getWarmupOps() { return warmupOps; } public void adjustStart(long startTime) { this.startTime = startTime; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkTaskResult.java000066400000000000000000000041121446271450100276430ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import java.util.ArrayList; import java.util.Collection; public class BenchmarkTaskResult { /** * Total benchmark ops done. */ private final long allOperations; /** * Measured benchmark ops done: total without sync iterations. */ private final long measuredOperations; private final Collection results; public BenchmarkTaskResult(long allOperations, long measuredOperations) { this.allOperations = allOperations; this.measuredOperations = measuredOperations; this.results = new ArrayList<>(); } public void add(Result result) { results.add(result); } public Collection getResults() { return results; } public long getAllOps() { return allOperations; } public long getMeasuredOps() { return measuredOperations; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/IterationResult.java000066400000000000000000000122761446271450100270760ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.TreeMultimap; import java.io.Serializable; import java.util.*; /** * Class contains all info returned by benchmark iteration or/and collected during benchmark iteration. */ public class IterationResult implements Serializable { private static final long serialVersionUID = 960397066774710819L; private static final Multimap EMPTY_MAP = new TreeMultimap<>(); private static final List EMPTY_LIST = Collections.emptyList(); private final BenchmarkParams benchmarkParams; private final IterationParams params; private final IterationResultMetaData metadata; private Collection primaryResults; private Multimap secondaryResults; public IterationResult(BenchmarkParams benchmarkParams, IterationParams params, IterationResultMetaData md) { this.benchmarkParams = benchmarkParams; this.params = params; this.metadata = md; this.primaryResults = EMPTY_LIST; this.secondaryResults = EMPTY_MAP; } public IterationResultMetaData getMetadata() { return metadata; } public void addResults(Collection rs) { for (Result r : rs) { addResult(r); } } public void addResult(Result result) { if (result.getRole().isPrimary()) { if (primaryResults == EMPTY_LIST) { primaryResults = Collections.singleton(result); } else if (primaryResults.size() == 1) { List newResults = new ArrayList<>(2); newResults.addAll(primaryResults); newResults.add(result); primaryResults = newResults; } else { primaryResults.add(result); } } if (result.getRole().isSecondary()) { if (secondaryResults == EMPTY_MAP) { secondaryResults = new TreeMultimap<>(); } secondaryResults.put(result.getLabel(), result); } } public Collection getRawPrimaryResults() { return primaryResults; } public Multimap getRawSecondaryResults() { return secondaryResults; } public Map getSecondaryResults() { Map answer = new TreeMap<>(); for (String label : secondaryResults.keys()) { Collection results = secondaryResults.get(label); Result next = results.iterator().next(); @SuppressWarnings("unchecked") Aggregator aggregator = next.getThreadAggregator(); Result result = aggregator.aggregate(results); answer.put(label, result); } // put all secondary derivative results on top: from primaries answer.putAll(produceDerivative(getPrimaryResult())); // add all secondary derivative results on top: from secondaries Map adds = new HashMap<>(); for (Result r : answer.values()) { adds.putAll(produceDerivative(r)); } answer.putAll(adds); return answer; } private Map produceDerivative(Result r) { Map map = new HashMap<>(); for (Object rr : r.getDerivativeResults()) { map.put(((Result) rr).getLabel(), (Result) rr); } return map; } public Result getPrimaryResult() { @SuppressWarnings("unchecked") Aggregator aggregator = primaryResults.iterator().next().getThreadAggregator(); return aggregator.aggregate(primaryResults); } public IterationParams getParams() { return params; } public BenchmarkParams getBenchmarkParams() { return benchmarkParams; } public String getScoreUnit() { return getPrimaryResult().getScoreUnit(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/IterationResultMetaData.java000066400000000000000000000033361446271450100304740ustar00rootroot00000000000000/* * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import java.io.Serializable; public class IterationResultMetaData implements Serializable { private static final long serialVersionUID = -8302904925038356897L; private final long allOps; private final long measuredOps; public IterationResultMetaData(long allOps, long measuredOps) { this.allOps = allOps; this.measuredOps = measuredOps; } public long getMeasuredOps() { return measuredOps; } public long getAllOps() { return allOps; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/RawResults.java000066400000000000000000000027531446271450100260530ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; public class RawResults { public double allOps; public double measuredOps; public long realTime; public long startTime; public long stopTime; public long getTime() { return (realTime > 0) ? realTime : (stopTime - startTime); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java000066400000000000000000000260051446271450100252120ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.openjdk.jmh.util.Deduplicator; import org.openjdk.jmh.util.ScoreFormatter; import org.openjdk.jmh.util.SingletonStatistics; import org.openjdk.jmh.util.Statistics; import java.io.PrintWriter; import java.io.Serializable; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; /** * Base class for all types of results that can be returned by a benchmark. */ public abstract class Result> implements Serializable { private static final long serialVersionUID = -7332879501317733312L; private static final Deduplicator DEDUP = new Deduplicator<>(); protected final ResultRole role; protected final String label; protected final String unit; protected final Statistics statistics; protected final AggregationPolicy policy; public Result(ResultRole role, String label, Statistics s, String unit, AggregationPolicy policy) { this.role = role; this.label = DEDUP.dedup(label); this.unit = DEDUP.dedup(unit); this.statistics = s; this.policy = policy; } protected static Statistics of(double v) { return new SingletonStatistics(v); } /** * Return the result label. * @return result label */ public String getLabel() { return label; } /** * Return the result role. * @return result role */ public ResultRole getRole() { return role; } /** * Return the statistics holding the subresults' values. * *

This method returns raw samples. The aggregation policy decides how to get the score * out of these raw samples. Use {@link #getScore()}, {@link #getScoreError()}, and * {@link #getScoreConfidence()} for scalar results.

* * @return statistics */ public Statistics getStatistics() { return statistics; } /** * The unit of the score for this result. * * @return String representation of the unit */ public final String getScoreUnit() { return unit; } /** * The score for this result. * * @return double representing the score * @see #getScoreError() */ public double getScore() { switch (policy) { case AVG: return statistics.getMean(); case SUM: return statistics.getSum(); case MAX: return statistics.getMax(); case MIN: return statistics.getMin(); default: throw new IllegalStateException("Unknown aggregation policy: " + policy); } } /** * The score error for this result. * @return score error, if available * @see #getScore() */ public double getScoreError() { switch (policy) { case AVG: return statistics.getMeanErrorAt(0.999); case SUM: case MIN: case MAX: return Double.NaN; default: throw new IllegalStateException("Unknown aggregation policy: " + policy); } } /** * The score confidence interval for this result. * @return score confidence interval, if available; if not, the CI will match {@link #getScore()} * @see #getScore() */ public double[] getScoreConfidence() { switch (policy) { case AVG: return statistics.getConfidenceIntervalAt(0.999); case MAX: case MIN: case SUM: double score = getScore(); return new double[] {score, score}; default: throw new IllegalStateException("Unknown aggregation policy: " + policy); } } /** * Get number of samples in the current result. * @return number of samples */ public long getSampleCount() { return statistics.getN(); } /** * Thread aggregator combines the thread results into iteration result. * @return thread aggregator */ protected abstract Aggregator getThreadAggregator(); /** * Iteration aggregator combines the iteration results into benchmar result. * @return iteration aggregator */ protected abstract Aggregator getIterationAggregator(); /** * Returns "0" result. This is used for un-biased aggregation of secondary results. * For instance, profilers might omit results in some iterations, thus we should pretend there were 0 results. * @return result that represents "empty" result, null if no sensible "empty" result can be created */ protected T getZeroResult() { return null; } /** * @return derivative results for this result. These do not participate in aggregation, * and computed on the spot from the aggregated result. */ protected Collection getDerivativeResults() { return Collections.emptyList(); } /** * Result as represented by a String. * * @return String with the result and unit */ @Override public String toString() { if (!Double.isNaN(getScoreError()) && !ScoreFormatter.isApproximate(getScore())) { return String.format("%s \u00B1(99.9%%) %s %s", ScoreFormatter.format(getScore()), ScoreFormatter.formatError(getScoreError()), getScoreUnit()); } else { return String.format("%s %s", ScoreFormatter.format(getScore()), getScoreUnit()); } } /** * Print extended result information * @return String with extended info */ public String extendedInfo() { return simpleExtendedInfo(); } protected String simpleExtendedInfo() { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); Statistics stats = getStatistics(); if (stats.getN() > 2 && !ScoreFormatter.isApproximate(getScore())) { double[] interval = getScoreConfidence(); pw.println(String.format(" %s \u00B1(99.9%%) %s %s [%s]", ScoreFormatter.format(getScore()), ScoreFormatter.formatError((interval[1] - interval[0]) / 2), getScoreUnit(), policy)); pw.println(String.format(" (min, avg, max) = (%s, %s, %s), stdev = %s%n" + " CI (99.9%%): [%s, %s] (assumes normal distribution)", ScoreFormatter.format(stats.getMin()), ScoreFormatter.format(stats.getMean()), ScoreFormatter.format(stats.getMax()), ScoreFormatter.formatError(stats.getStandardDeviation()), ScoreFormatter.format(interval[0]), ScoreFormatter.format(interval[1])) ); } else { pw.println(String.format(" %s %s", ScoreFormatter.format(stats.getMean()), getScoreUnit())); } pw.close(); return sw.toString(); } protected String distributionExtendedInfo() { Statistics stats = getStatistics(); StringBuilder sb = new StringBuilder(); if (stats.getN() > 2) { sb.append(" N = ").append(stats.getN()).append("\n"); double[] interval = stats.getConfidenceIntervalAt(0.999); sb.append(String.format(" mean = %s \u00B1(99.9%%) %s", ScoreFormatter.format(10, stats.getMean()), ScoreFormatter.formatError((interval[1] - interval[0]) / 2) )); sb.append(" ").append(getScoreUnit()).append("\n"); printHisto(stats, sb); printPercentiles(stats, sb); } return sb.toString(); } private void printPercentiles(Statistics stats, StringBuilder sb) { sb.append("\n Percentiles, ").append(getScoreUnit()).append(":\n"); for (double p : new double[]{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 0.99999, 0.999999, 1.0}) { sb.append(String.format(" %11s = %s %s\n", "p(" + String.format("%.4f", p * 100) + ")", ScoreFormatter.format(10, stats.getPercentile(p * 100)), getScoreUnit() )); } } static class LazyProps { private static final int MIN_HISTOGRAM_BINS = Integer.getInteger("jmh.histogramBins", 10); } private void printHisto(Statistics stats, StringBuilder sb) { sb.append("\n Histogram, ").append(getScoreUnit()).append(":\n"); double min = stats.getMin(); double max = stats.getMax(); double binSize = Math.pow(10, Math.floor(Math.log10(max - min))); min = Math.floor(min / binSize) * binSize; max = Math.ceil(max / binSize) * binSize; double range = max - min; double[] levels; if (range > 0) { while ((range / binSize) < LazyProps.MIN_HISTOGRAM_BINS) { binSize /= 2; } int binCount = Math.max(2, (int) Math.ceil(range / binSize)); levels = new double[binCount]; for (int c = 0; c < binCount; c++) { levels[c] = min + (c * binSize); } } else { levels = new double[] { stats.getMin() - Math.ulp(stats.getMin()), stats.getMax() + Math.ulp(stats.getMax()) }; } int width = ScoreFormatter.format(1, max).length(); int[] histo = stats.getHistogram(levels); for (int c = 0; c < levels.length - 1; c++) { sb.append(String.format(" [%" + width + "s, %" + width + "s) = %d %n", ScoreFormatter.formatExact(width, levels[c]), ScoreFormatter.formatExact(width, levels[c + 1]), histo[c])); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/ResultRole.java000066400000000000000000000035621446271450100260370ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; public enum ResultRole { /** * Participates in primary metric calculation. */ PRIMARY, /** * Participates in secondary metric calculations. */ SECONDARY, /** * Same as {@link #SECONDARY}, but always recomputed. */ SECONDARY_DERIVATIVE, /** * Does not participate in any metric, garbage result. */ OMITTED, ; public boolean isPrimary() { return this == PRIMARY; } public boolean isSecondary() { return this == SECONDARY || this == SECONDARY_DERIVATIVE; } public boolean isDerivative() { return this == SECONDARY_DERIVATIVE; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/RunResult.java000066400000000000000000000063101446271450100256740ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.openjdk.jmh.infra.BenchmarkParams; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.Map; /** * Complete run result. * Contains the iteration results. */ public class RunResult implements Serializable { private static final long serialVersionUID = 6467912427356048369L; private final Collection benchmarkResults; private final BenchmarkParams params; public RunResult(BenchmarkParams params, Collection data) { this.benchmarkResults = data; this.params = params; } public Collection getBenchmarkResults() { return benchmarkResults; } public Result getPrimaryResult() { return getAggregatedResult().getPrimaryResult(); } public Map getSecondaryResults() { return getAggregatedResult().getSecondaryResults(); } /** * Return the benchmark result, as if all iterations from all sub-benchmark results * were merged in a single result. * * @return merged benchmark result */ public BenchmarkResult getAggregatedResult() { if (benchmarkResults.isEmpty()) { return null; } Collection results = new ArrayList<>(); for (BenchmarkResult r : benchmarkResults) { results.addAll(r.getIterationResults()); } BenchmarkResult result = new BenchmarkResult(params, results); for (BenchmarkResult br : benchmarkResults) { for (String k : br.getBenchmarkResults().keys()) { for (Result r : br.getBenchmarkResults().get(k)) { result.addBenchmarkResult(r); } } } return result; } public BenchmarkParams getParams() { return params; } public static final Comparator DEFAULT_SORT_COMPARATOR = Comparator.comparing(o -> o.params); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java000066400000000000000000000122541446271450100271740ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.SampleBuffer; import org.openjdk.jmh.util.Statistics; import java.util.Arrays; import java.util.Collection; import java.util.concurrent.TimeUnit; /** * Result class that samples operation time. */ public class SampleTimeResult extends Result { private static final long serialVersionUID = -295298353763294757L; private final SampleBuffer buffer; private final TimeUnit outputTimeUnit; public SampleTimeResult(ResultRole role, String label, SampleBuffer buffer, TimeUnit outputTimeUnit) { this(role, label, buffer, TimeValue.tuToString(outputTimeUnit) + "/op", outputTimeUnit); } SampleTimeResult(ResultRole role, String label, SampleBuffer buffer, String unit, TimeUnit outputTimeUnit) { super(role, label, of(buffer, outputTimeUnit), unit, AggregationPolicy.AVG); this.buffer = buffer; this.outputTimeUnit = outputTimeUnit; } private static Statistics of(SampleBuffer buffer, TimeUnit outputTimeUnit) { double tuMultiplier = 1.0D * outputTimeUnit.convert(1, TimeUnit.DAYS) / TimeUnit.NANOSECONDS.convert(1, TimeUnit.DAYS); return buffer.getStatistics(tuMultiplier); } @Override protected Collection getDerivativeResults() { String s = role.isPrimary() ? "" : (label + ":"); return Arrays.asList( new ScalarDerivativeResult(s + "p0.00", statistics.getPercentile(0), getScoreUnit(), AggregationPolicy.AVG), new ScalarDerivativeResult(s + "p0.50", statistics.getPercentile(50), getScoreUnit(), AggregationPolicy.AVG), new ScalarDerivativeResult(s + "p0.90", statistics.getPercentile(90), getScoreUnit(), AggregationPolicy.AVG), new ScalarDerivativeResult(s + "p0.95", statistics.getPercentile(95), getScoreUnit(), AggregationPolicy.AVG), new ScalarDerivativeResult(s + "p0.99", statistics.getPercentile(99), getScoreUnit(), AggregationPolicy.AVG), new ScalarDerivativeResult(s + "p0.999", statistics.getPercentile(99.9), getScoreUnit(), AggregationPolicy.AVG), new ScalarDerivativeResult(s + "p0.9999", statistics.getPercentile(99.99), getScoreUnit(), AggregationPolicy.AVG), new ScalarDerivativeResult(s + "p1.00", statistics.getPercentile(100), getScoreUnit(), AggregationPolicy.AVG) ); } @Override public String extendedInfo() { return distributionExtendedInfo(); } @Override protected Aggregator getThreadAggregator() { return new JoiningAggregator(); } @Override protected Aggregator getIterationAggregator() { return new JoiningAggregator(); } /** * Always add up all the samples into final result. * This will allow aggregate result to achieve better accuracy. */ static class JoiningAggregator implements Aggregator { @Override public SampleTimeResult aggregate(Collection results) { SampleBuffer buffer = new SampleBuffer(); TimeUnit tu = null; for (SampleTimeResult r : results) { buffer.addAll(r.buffer); if (tu == null) { tu = r.outputTimeUnit; } else if (!tu.equals(r.outputTimeUnit)){ throw new IllegalStateException("Combining the results with different timeunits"); } } return new SampleTimeResult( AggregatorUtils.aggregateRoles(results), AggregatorUtils.aggregateLabels(results), buffer, AggregatorUtils.aggregateUnits(results), tu ); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/ScalarDerivativeResult.java000066400000000000000000000056661446271450100303750ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.openjdk.jmh.util.ListStatistics; import org.openjdk.jmh.util.Statistics; import java.util.Collection; public class ScalarDerivativeResult extends Result { private static final long serialVersionUID = 3407232747805728586L; public ScalarDerivativeResult(String label, double n, String unit, AggregationPolicy policy) { this(label, of(n), unit, policy); } ScalarDerivativeResult(String label, Statistics s, String unit, AggregationPolicy policy) { super(ResultRole.SECONDARY_DERIVATIVE, label, s, unit, policy); } @Override protected Aggregator getThreadAggregator() { return new ScalarResultAggregator(); } @Override protected Aggregator getIterationAggregator() { return new ScalarResultAggregator(); } @Override protected ScalarDerivativeResult getZeroResult() { return new ScalarDerivativeResult(label, 0, unit, policy); } static class ScalarResultAggregator implements Aggregator { @Override public ScalarDerivativeResult aggregate(Collection results) { ListStatistics stats = new ListStatistics(); for (ScalarDerivativeResult r : results) { stats.addValue(r.getScore()); } return new ScalarDerivativeResult( AggregatorUtils.aggregateLabels(results), stats, AggregatorUtils.aggregateUnits(results), AggregatorUtils.aggregatePolicies(results) ); } } @Override public String extendedInfo() { return ""; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/ScalarResult.java000066400000000000000000000053361446271450100263440ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.openjdk.jmh.util.ListStatistics; import org.openjdk.jmh.util.Statistics; import java.util.Collection; public class ScalarResult extends Result { private static final long serialVersionUID = 3407232747805728586L; public ScalarResult(String label, double n, String unit, AggregationPolicy policy) { this(label, of(n), unit, policy); } ScalarResult(String label, Statistics s, String unit, AggregationPolicy policy) { super(ResultRole.SECONDARY, label, s, unit, policy); } @Override protected Aggregator getThreadAggregator() { return new ScalarResultAggregator(); } @Override protected Aggregator getIterationAggregator() { return new ScalarResultAggregator(); } @Override protected ScalarResult getZeroResult() { return new ScalarResult(label, 0, unit, policy); } static class ScalarResultAggregator implements Aggregator { @Override public ScalarResult aggregate(Collection results) { ListStatistics stats = new ListStatistics(); for (ScalarResult r : results) { stats.addValue(r.getScore()); } return new ScalarResult( AggregatorUtils.aggregateLabels(results), stats, AggregatorUtils.aggregateUnits(results), AggregatorUtils.aggregatePolicies(results) ); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/SingleShotResult.java000066400000000000000000000065431446271450100272170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.ListStatistics; import org.openjdk.jmh.util.Statistics; import java.util.Collection; import java.util.concurrent.TimeUnit; /** * Result class that stores once operation execution time. */ public class SingleShotResult extends Result { private static final long serialVersionUID = -1251578870918524737L; public SingleShotResult(ResultRole role, String label, long duration, TimeUnit outputTimeUnit) { // TODO: Transition interface, should be removed when we decide it is OK to break the publicly leaked API. this(role, label, duration, 1, outputTimeUnit); } public SingleShotResult(ResultRole role, String label, long duration, long ops, TimeUnit outputTimeUnit) { this(role, label, of(1.0D * duration / ops / TimeUnit.NANOSECONDS.convert(1, outputTimeUnit)), TimeValue.tuToString(outputTimeUnit) + "/op"); } SingleShotResult(ResultRole mode, String label, Statistics s, String unit) { super(mode, label, s, unit, AggregationPolicy.AVG); } @Override public String extendedInfo() { return distributionExtendedInfo(); } @Override protected Aggregator getThreadAggregator() { return new AveragingAggregator(); } @Override protected Aggregator getIterationAggregator() { return new AveragingAggregator(); } /** * Averages the time on all levels. */ static class AveragingAggregator implements Aggregator { @Override public SingleShotResult aggregate(Collection results) { ListStatistics stat = new ListStatistics(); for (SingleShotResult r : results) { stat.addValue(r.getScore()); } return new SingleShotResult( AggregatorUtils.aggregateRoles(results), AggregatorUtils.aggregateLabels(results), stat, AggregatorUtils.aggregateUnits(results) ); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/TextResult.java000066400000000000000000000037751446271450100260700ustar00rootroot00000000000000/* * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; public class TextResult extends Result { private static final long serialVersionUID = 6871141606856800453L; final String output; final String label; public TextResult(String output, String label) { super(ResultRole.SECONDARY, label, of(Double.NaN), "---", AggregationPolicy.AVG); this.output = output; this.label = label; } @Override protected Aggregator getThreadAggregator() { return new TextResultAggregator(); } @Override protected Aggregator getIterationAggregator() { return new TextResultAggregator(); } @Override public String toString() { return "(text only)"; } @Override public String extendedInfo() { return output; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/TextResultAggregator.java000066400000000000000000000035631446271450100300660ustar00rootroot00000000000000/* * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import java.util.Collection; class TextResultAggregator implements Aggregator { @Override public TextResult aggregate(Collection results) { StringBuilder output = new StringBuilder(); String label = null; for (TextResult r : results) { output.append(r.output); if (label == null) { label = r.label; } else if (!label.equalsIgnoreCase(r.label)) { throw new IllegalStateException("Trying to aggregate different labels: " + label + ", " + r.label); } } return new TextResult(output.toString(), label); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/ThroughputResult.java000066400000000000000000000063641446271450100273120ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.ListStatistics; import org.openjdk.jmh.util.Statistics; import java.util.Collection; import java.util.concurrent.TimeUnit; /** * Result class that counts the number of operations performed during a specified unit of time. */ public class ThroughputResult extends Result { private static final long serialVersionUID = 7269598073169413322L; public ThroughputResult(ResultRole role, String label, double operations, long durationNs, TimeUnit outputTimeUnit) { this(role, label, of(operations * TimeUnit.NANOSECONDS.convert(1, outputTimeUnit) / durationNs), "ops/" + TimeValue.tuToString(outputTimeUnit), AggregationPolicy.SUM); } ThroughputResult(ResultRole role, String label, Statistics s, String unit, AggregationPolicy policy) { super(role, label, s, unit, policy); } @Override protected Aggregator getThreadAggregator() { return new ThroughputAggregator(AggregationPolicy.SUM); } @Override protected Aggregator getIterationAggregator() { return new ThroughputAggregator(AggregationPolicy.AVG); } static class ThroughputAggregator implements Aggregator { private final AggregationPolicy policy; ThroughputAggregator(AggregationPolicy policy) { this.policy = policy; } @Override public ThroughputResult aggregate(Collection results) { ListStatistics stat = new ListStatistics(); for (ThroughputResult r : results) { stat.addValue(r.getScore()); } return new ThroughputResult( AggregatorUtils.aggregateRoles(results), AggregatorUtils.aggregateLabels(results), stat, AggregatorUtils.aggregateUnits(results), policy ); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/format/000077500000000000000000000000001446271450100243565ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java000066400000000000000000000333031446271450100303440ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results.format; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.util.Statistics; import org.openjdk.jmh.util.Utils; import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; import java.util.Collection; import java.util.Map; class JSONResultFormat implements ResultFormat { private static final boolean PRINT_RAW_DATA = Boolean.parseBoolean(System.getProperty("jmh.json.rawData", "true")); private final PrintStream out; public JSONResultFormat(PrintStream out) { this.out = out; } @Override public void writeOut(Collection results) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); boolean first = true; pw.println("["); for (RunResult runResult : results) { BenchmarkParams params = runResult.getParams(); if (first) { first = false; pw.println(); } else { pw.println(","); } pw.println("{"); pw.println("\"jmhVersion\" : \"" + params.getJmhVersion() + "\","); pw.println("\"benchmark\" : \"" + params.getBenchmark() + "\","); pw.println("\"mode\" : \"" + params.getMode().shortLabel() + "\","); pw.println("\"threads\" : " + params.getThreads() + ","); pw.println("\"forks\" : " + params.getForks() + ","); pw.println("\"jvm\" : " + toJsonString(params.getJvm()) + ","); // if empty, write an empty array. pw.println("\"jvmArgs\" : ["); printStringArray(pw, params.getJvmArgs()); pw.println("],"); pw.println("\"jdkVersion\" : " + toJsonString(params.getJdkVersion()) + ","); pw.println("\"vmName\" : " + toJsonString(params.getVmName()) + ","); pw.println("\"vmVersion\" : " + toJsonString(params.getVmVersion()) + ","); pw.println("\"warmupIterations\" : " + params.getWarmup().getCount() + ","); pw.println("\"warmupTime\" : \"" + params.getWarmup().getTime() + "\","); pw.println("\"warmupBatchSize\" : " + params.getWarmup().getBatchSize() + ","); pw.println("\"measurementIterations\" : " + params.getMeasurement().getCount() + ","); pw.println("\"measurementTime\" : \"" + params.getMeasurement().getTime() + "\","); pw.println("\"measurementBatchSize\" : " + params.getMeasurement().getBatchSize() + ","); if (!params.getParamsKeys().isEmpty()) { pw.println("\"params\" : {"); pw.println(emitParams(params)); pw.println("},"); } Result primaryResult = runResult.getPrimaryResult(); pw.println("\"primaryMetric\" : {"); pw.println("\"score\" : " + emit(primaryResult.getScore()) + ","); pw.println("\"scoreError\" : " + emit(primaryResult.getScoreError()) + ","); pw.println("\"scoreConfidence\" : " + emit(primaryResult.getScoreConfidence()) + ","); pw.println(emitPercentiles(primaryResult.getStatistics())); pw.println("\"scoreUnit\" : \"" + primaryResult.getScoreUnit() + "\","); switch (params.getMode()) { case SampleTime: pw.println("\"rawDataHistogram\" :"); pw.println(getRawData(runResult, true)); break; default: pw.println("\"rawData\" :"); pw.println(getRawData(runResult, false)); } pw.println("},"); // primaryMetric end Collection secondaries = new ArrayList<>(); for (Map.Entry e : runResult.getSecondaryResults().entrySet()) { String secondaryName = e.getKey(); Result result = e.getValue(); StringBuilder sb = new StringBuilder(); sb.append("\"").append(secondaryName).append("\" : {"); sb.append("\"score\" : ").append(emit(result.getScore())).append(","); sb.append("\"scoreError\" : ").append(emit(result.getScoreError())).append(","); sb.append("\"scoreConfidence\" : ").append(emit(result.getScoreConfidence())).append(","); sb.append(emitPercentiles(result.getStatistics())); sb.append("\"scoreUnit\" : \"").append(result.getScoreUnit()).append("\","); sb.append("\"rawData\" : "); Collection l2 = new ArrayList<>(); for (BenchmarkResult benchmarkResult : runResult.getBenchmarkResults()) { Collection scores = new ArrayList<>(); for (IterationResult r : benchmarkResult.getIterationResults()) { Result rr = r.getSecondaryResults().get(secondaryName); if (rr != null) { scores.add(emit(rr.getScore())); } } l2.add(printMultiple(scores, "[", "]")); } sb.append(printMultiple(l2, "[", "]")); sb.append("}"); secondaries.add(sb.toString()); } pw.println("\"secondaryMetrics\" : {"); pw.println(printMultiple(secondaries, "", "")); pw.println("}"); pw.print("}"); // benchmark end } pw.println("]"); out.println(tidy(sw.toString())); } private String getRawData(RunResult runResult, boolean histogram) { StringBuilder sb = new StringBuilder(); Collection runs = new ArrayList<>(); if (PRINT_RAW_DATA) { for (BenchmarkResult benchmarkResult : runResult.getBenchmarkResults()) { Collection iterations = new ArrayList<>(); for (IterationResult r : benchmarkResult.getIterationResults()) { if (histogram) { Collection singleIter = new ArrayList<>(); for (Map.Entry item : Utils.adaptForLoop(r.getPrimaryResult().getStatistics().getRawData())) { singleIter.add("< " + emit(item.getKey()) + "; " + item.getValue() + " >"); } iterations.add(printMultiple(singleIter, "[", "]")); } else { iterations.add(emit(r.getPrimaryResult().getScore())); } } runs.add(printMultiple(iterations, "[", "]")); } } sb.append(printMultiple(runs, "[", "]")); return sb.toString(); } private String emitParams(BenchmarkParams params) { StringBuilder sb = new StringBuilder(); boolean isFirst = true; for (String k : params.getParamsKeys()) { if (isFirst) { isFirst = false; } else { sb.append(", "); } sb.append("\"").append(k).append("\" : "); sb.append(toJsonString(params.getParam(k))); } return sb.toString(); } private String emitPercentiles(Statistics stats) { StringBuilder sb = new StringBuilder(); sb.append("\"scorePercentiles\" : {"); boolean firstPercentile = true; for (double p : new double[]{0.00, 50.0, 90, 95, 99, 99.9, 99.99, 99.999, 99.9999, 100}) { if (firstPercentile) { firstPercentile = false; } else { sb.append(","); } double v = stats.getPercentile(p); sb.append("\"").append(emit(p)).append("\" : "); sb.append(emit(v)); } sb.append("},"); return sb.toString(); } private String emit(double[] ds) { StringBuilder sb = new StringBuilder(); boolean isFirst = true; sb.append("["); for (double d : ds) { if (isFirst) { isFirst = false; } else { sb.append(","); } sb.append(emit(d)); } sb.append("]"); return sb.toString(); } private String emit(double d) { if (d != d) return "\"NaN\""; if (d == Double.NEGATIVE_INFINITY) return "\"-INF\""; if (d == Double.POSITIVE_INFINITY) return "\"+INF\""; return String.valueOf(d); } /** * Escaping for a JSON string. Does the typical escaping of double quotes and backslash. * Also escapes characters that are handled by the tidying process, so that every ASCII * character makes it correctly into the JSON output. Control characters are filtered. */ static String toJsonString(String s) { StringBuilder sb = new StringBuilder(); sb.append("\""); for (char c : s.toCharArray()) { if (Character.isISOControl(c)) { continue; } switch (c) { // use & as escape character to escape the tidying case '&': sb.append("&&"); break; // we cannot escape to \\\\ since this would create sequences interpreted by the tidying case '\\': sb.append("&/"); break; case '"': sb.append("&'"); break; // escape spacial chars for the tidying formatting below that might appear in a string case ',': sb.append(";"); break; case '[': sb.append("<"); break; case ']': sb.append(">"); break; case '<': sb.append("&-"); break; case '>': sb.append("&="); break; case ';': sb.append("&:"); break; case '{': sb.append("&("); break; case '}': sb.append("&)"); break; default: sb.append(c); } } sb.append("\""); return sb.toString(); } static String tidy(String s) { s = s.replaceAll("\r", ""); s = s.replaceAll("\n", " "); s = s.replaceAll(",", ",\n"); s = s.replaceAll("\\{", "{\n"); s = s.replaceAll("\\[", "[\n"); s = s.replaceAll("\\}", "\n}\n"); s = s.replaceAll("\\]", "\n]\n"); s = s.replaceAll("\\]\n,\n", "],\n"); s = s.replaceAll("\\}\n,\n", "},\n"); s = s.replaceAll("\n( *)\n", "\n"); // Keep these inline: s = s.replaceAll(";", ","); s = s.replaceAll("\\<", "["); s = s.replaceAll("\\>", "]"); // translate back from string escaping to keep all string characters intact s = s.replaceAll("&:", ";"); s = s.replaceAll("&'", "\\\\\""); s = s.replaceAll("&\\(", "{"); s = s.replaceAll("&\\)", "}"); s = s.replaceAll("&-", "<"); s = s.replaceAll("&=", ">"); s = s.replaceAll("&/", "\\\\\\\\"); s = s.replaceAll("&&", "&"); String[] lines = s.split("\n"); StringBuilder sb = new StringBuilder(); int ident = 0; String prevL = null; for (String l : lines) { if (prevL != null && (prevL.endsWith("{") || prevL.endsWith("["))) { ident++; } if (l.equals("}") || l.equals("]") || l.equals("},") || l.equals("],")) { ident--; } for (int c = 0; c < ident; c++) { sb.append(" "); } sb.append(l.trim()); sb.append("\n"); prevL = l; } return sb.toString(); } private String printMultiple(Collection elements, String leftBracket, String rightBracket) { StringBuilder sb = new StringBuilder(); sb.append(leftBracket); boolean isFirst = true; for (String e : elements) { if (isFirst) { isFirst = false; } else { sb.append(","); } sb.append(e); } sb.append(rightBracket); return sb.toString(); } private static void printStringArray(PrintWriter pw, Collection col) { boolean isFirst = true; for (String e : col) { if (isFirst) { isFirst = false; } else { pw.print(','); } pw.print(toJsonString(e)); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/format/LaTeXResultFormat.java000066400000000000000000000120451446271450100305500ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results.format; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.util.ClassUtils; import org.openjdk.jmh.util.ScoreFormatter; import java.io.PrintStream; import java.util.Collection; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; class LaTeXResultFormat implements ResultFormat { private final PrintStream out; public LaTeXResultFormat(PrintStream out) { this.out = out; } @Override public void writeOut(Collection results) { SortedSet params = new TreeSet<>(); Set benchNames = new HashSet<>(); Set units = new HashSet<>(); for (RunResult rr : results) { String benchmark = rr.getParams().getBenchmark(); benchNames.add(benchmark); params.addAll(rr.getParams().getParamsKeys()); units.add(rr.getPrimaryResult().getScoreUnit()); Map secondaries = rr.getSecondaryResults(); for (String label : secondaries.keySet()) { benchNames.add(benchmark + ":" + label); units.add(secondaries.get(label).getScoreUnit()); } } boolean singleUnit = (units.size() == 1); String unit = singleUnit ? units.iterator().next() : null; Map prefixes = ClassUtils.denseClassNames(benchNames); printHeader(params, singleUnit, unit); for (RunResult rr : results) { BenchmarkParams bp = rr.getParams(); String benchmark = bp.getBenchmark(); Result res = rr.getPrimaryResult(); printLine(benchmark, bp, params, prefixes, singleUnit, res); Map secondaries = rr.getSecondaryResults(); for (String label : secondaries.keySet()) { Result subRes = secondaries.get(label); printLine(benchmark + ":" + label, bp, params, prefixes, singleUnit, subRes); } } printFooter(); } private void printHeader(SortedSet params, boolean singleUnit, String unit) { out.print("\\begin{tabular}{r|"); for (String p : params) { out.print("l|"); } out.print("rl" + (singleUnit ? "" : "l") + "}\n"); out.print(" \\multicolumn{1}{c|}{\\texttt{Benchmark}} & "); for (String p : params) { out.printf("\\texttt{%s} & ", p); } out.print("\\multicolumn{" + (singleUnit ? 2 : 3) + "}{c}{\\texttt{Score" + (singleUnit ? ", " + unit : "") + "}} \\\\\n"); out.print("\\hline\n"); } private void printFooter() { out.print("\\end{tabular}"); } private void printLine(String label, BenchmarkParams benchParams, SortedSet params, Map prefixes, boolean singleUnit, Result res) { out.printf("\\texttt{%s} & ", escape(prefixes.get(label))); for (String p : params) { out.printf("\\texttt{%s} & ", escape(benchParams.getParam(p))); } out.printf("\\texttt{%s} & ", ScoreFormatter.formatLatex(res.getScore())); if (!Double.isNaN(res.getScoreError()) && !ScoreFormatter.isApproximate(res.getScore())) { out.printf("\\scriptsize $\\pm$ \\texttt{%s} ", ScoreFormatter.formatError(res.getScoreError())); } if (!singleUnit) { out.print("& "); out.printf("\\texttt{%s}", escape(res.getScoreUnit())); } out.print(" \\\\\n"); } private static String escape(String s) { return s.replaceAll("_", "\\\\_") .replaceAll("#", "\\\\#") .replaceAll("\\{", "\\\\{") .replaceAll("\\}", "\\\\}"); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/format/ResultFormat.java000066400000000000000000000026051446271450100276530ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results.format; import org.openjdk.jmh.results.RunResult; import java.util.Collection; public interface ResultFormat { void writeOut(Collection results); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/format/ResultFormatFactory.java000066400000000000000000000064541446271450100312110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results.format; import org.openjdk.jmh.results.RunResult; import java.io.IOException; import java.io.PrintStream; import java.util.Collection; public class ResultFormatFactory { private ResultFormatFactory() {} /** * Get the instance of ResultFormat of given type which writes the result to file * @param type result format type * @param file target file * @return result format */ public static ResultFormat getInstance(final ResultFormatType type, final String file) { return results -> { try { PrintStream pw = new PrintStream(file, "UTF-8"); ResultFormat rf = getInstance(type, pw); rf.writeOut(results); pw.flush(); pw.close(); } catch (IOException e) { throw new IllegalStateException(e); } }; } /** * Get the instance of ResultFormat of given type which write the result to out. * It is a user responsibility to initialize and finish the out as appropriate. * * @param type result format type * @param out target out * @return result format. */ public static ResultFormat getInstance(ResultFormatType type, PrintStream out) { switch (type) { case TEXT: return new TextResultFormat(out); case CSV: return new XSVResultFormat(out, ","); case SCSV: /* * Since some implementations, notably Excel, think it is a good * idea to hijack the CSV standard, and use semi-colon instead of * comma in some locales, this is the specialised * Semi-Colon Separated Values formatter. */ return new XSVResultFormat(out, ";"); case JSON: return new JSONResultFormat(out); case LATEX: return new LaTeXResultFormat(out); default: throw new IllegalStateException("Unsupported result format: " + type); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/format/ResultFormatType.java000066400000000000000000000024731446271450100305200ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results.format; public enum ResultFormatType { TEXT, CSV, SCSV, JSON, LATEX, } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java000066400000000000000000000176041446271450100305250ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results.format; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.util.ClassUtils; import org.openjdk.jmh.util.ScoreFormatter; import java.io.PrintStream; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; class TextResultFormat implements ResultFormat { private final PrintStream out; public TextResultFormat(PrintStream out) { this.out = out; } @Override public void writeOut(Collection runResults) { final int COLUMN_PAD = 2; Collection benchNames = new ArrayList<>(); for (RunResult runResult : runResults) { benchNames.add(runResult.getParams().getBenchmark()); for (String label : runResult.getSecondaryResults().keySet()) { benchNames.add(runResult.getParams().getBenchmark() + ":" + label); } } Map benchPrefixes = ClassUtils.denseClassNames(benchNames); // determine name column length int nameLen = "Benchmark".length(); for (String prefix : benchPrefixes.values()) { nameLen = Math.max(nameLen, prefix.length()); } // determine param lengths Map paramLengths = new HashMap<>(); SortedSet params = new TreeSet<>(); for (RunResult runResult : runResults) { BenchmarkParams bp = runResult.getParams(); for (String k : bp.getParamsKeys()) { params.add(k); Integer len = paramLengths.get(k); if (len == null) { len = ("(" + k + ")").length() + COLUMN_PAD; } paramLengths.put(k, Math.max(len, bp.getParam(k).length() + COLUMN_PAD)); } } // determine column lengths for other columns int modeLen = "Mode".length(); int samplesLen = "Cnt".length(); int scoreLen = "Score".length(); int scoreErrLen = "Error".length(); int unitLen = "Units".length(); for (RunResult res : runResults) { Result primRes = res.getPrimaryResult(); modeLen = Math.max(modeLen, res.getParams().getMode().shortLabel().length()); samplesLen = Math.max(samplesLen, String.format("%d", primRes.getSampleCount()).length()); scoreLen = Math.max(scoreLen, ScoreFormatter.format(primRes.getScore()).length()); scoreErrLen = Math.max(scoreErrLen, ScoreFormatter.format(primRes.getScoreError()).length()); unitLen = Math.max(unitLen, primRes.getScoreUnit().length()); for (Result subRes : res.getSecondaryResults().values()) { samplesLen = Math.max(samplesLen, String.format("%d", subRes.getSampleCount()).length()); scoreLen = Math.max(scoreLen, ScoreFormatter.format(subRes.getScore()).length()); scoreErrLen = Math.max(scoreErrLen, ScoreFormatter.format(subRes.getScoreError()).length()); unitLen = Math.max(unitLen, subRes.getScoreUnit().length()); } } modeLen += COLUMN_PAD; samplesLen += COLUMN_PAD; scoreLen += COLUMN_PAD; scoreErrLen += COLUMN_PAD - 1; // digest a single character for +- separator unitLen += COLUMN_PAD; out.printf("%-" + nameLen + "s", "Benchmark"); for (String k : params) { out.printf("%" + paramLengths.get(k) + "s", "(" + k + ")"); } out.printf("%" + modeLen + "s", "Mode"); out.printf("%" + samplesLen + "s", "Cnt"); out.printf("%" + scoreLen + "s", "Score"); out.print(" "); out.printf("%" + scoreErrLen + "s", "Error"); out.printf("%" + unitLen + "s", "Units"); out.println(); for (RunResult res : runResults) { { out.printf("%-" + nameLen + "s", benchPrefixes.get(res.getParams().getBenchmark())); for (String k : params) { String v = res.getParams().getParam(k); out.printf("%" + paramLengths.get(k) + "s", (v == null) ? "N/A" : v); } Result pRes = res.getPrimaryResult(); out.printf("%" + modeLen + "s", res.getParams().getMode().shortLabel()); if (pRes.getSampleCount() > 1) { out.printf("%" + samplesLen + "d", pRes.getSampleCount()); } else { out.printf("%" + samplesLen + "s", ""); } out.print(ScoreFormatter.format(scoreLen, pRes.getScore())); if (!Double.isNaN(pRes.getScoreError()) && !ScoreFormatter.isApproximate(pRes.getScore())) { out.print(" \u00B1"); out.print(ScoreFormatter.formatError(scoreErrLen, pRes.getScoreError())); } else { out.print(" "); out.printf("%" + scoreErrLen + "s", ""); } out.printf("%" + unitLen + "s", pRes.getScoreUnit()); out.println(); } for (Map.Entry e : res.getSecondaryResults().entrySet()) { String label = e.getKey(); Result subRes = e.getValue(); out.printf("%-" + nameLen + "s", benchPrefixes.get(res.getParams().getBenchmark() + ":" + label)); for (String k : params) { String v = res.getParams().getParam(k); out.printf("%" + paramLengths.get(k) + "s", (v == null) ? "N/A" : v); } out.printf("%" + modeLen + "s", res.getParams().getMode().shortLabel()); if (subRes.getSampleCount() > 1) { out.printf("%" + samplesLen + "d", subRes.getSampleCount()); } else { out.printf("%" + samplesLen + "s", ""); } out.print(ScoreFormatter.format(scoreLen, subRes.getScore())); if (!Double.isNaN(subRes.getScoreError()) && !ScoreFormatter.isApproximate(subRes.getScore())) { out.print(" \u00B1"); out.print(ScoreFormatter.formatError(scoreErrLen, subRes.getScoreError())); } else { out.print(" "); out.printf("%" + scoreErrLen + "s", ""); } out.printf("%" + unitLen + "s", subRes.getScoreUnit()); out.println(); } } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/results/format/XSVResultFormat.java000066400000000000000000000112721446271450100302540ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results.format; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import java.io.PrintStream; import java.util.Collection; import java.util.SortedSet; import java.util.TreeSet; /* * CSV formatter follows the provisions of http://tools.ietf.org/html/rfc4180 */ class XSVResultFormat implements ResultFormat { private final PrintStream out; private final String delimiter; public XSVResultFormat(PrintStream out, String delimiter) { this.out = out; this.delimiter = delimiter; } @Override public void writeOut(Collection results) { SortedSet params = new TreeSet<>(); for (RunResult res : results) { params.addAll(res.getParams().getParamsKeys()); } printHeader(params); for (RunResult rr : results) { BenchmarkParams benchParams = rr.getParams(); Result res = rr.getPrimaryResult(); printLine(benchParams.getBenchmark(), benchParams, params, res); for (String label : rr.getSecondaryResults().keySet()) { Result subRes = rr.getSecondaryResults().get(label); printLine(benchParams.getBenchmark() + ":" + subRes.getLabel(), benchParams, params, subRes); } } } private void printHeader(SortedSet params) { out.print("\"Benchmark\""); out.print(delimiter); out.print("\"Mode\""); out.print(delimiter); out.print("\"Threads\""); out.print(delimiter); out.print("\"Samples\""); out.print(delimiter); out.print("\"Score\""); out.print(delimiter); out.printf("\"Score Error (%.1f%%)\"", 99.9); out.print(delimiter); out.print("\"Unit\""); for (String k : params) { out.print(delimiter); out.print("\"Param: " + k + "\""); } out.print("\r\n"); } private void printLine(String label, BenchmarkParams benchmarkParams, SortedSet params, Result result) { out.print("\""); out.print(label); out.print("\""); out.print(delimiter); out.print("\""); out.print(benchmarkParams.getMode().shortLabel()); out.print("\""); out.print(delimiter); out.print(emit(benchmarkParams.getThreads())); out.print(delimiter); out.print(emit(result.getSampleCount())); out.print(delimiter); out.print(emit(result.getScore())); out.print(delimiter); out.print(emit(result.getScoreError())); out.print(delimiter); out.print("\""); out.print(result.getScoreUnit()); out.print("\""); for (String p : params) { out.print(delimiter); String v = benchmarkParams.getParam(p); if (v != null) { out.print(emit(v)); } } out.print("\r\n"); } private String emit(String v) { if (v.contains(delimiter) || v.contains(" ") || v.contains("\n") || v.contains("\r") || v.contains("\"")) { return "\"" + v.replaceAll("\"", "\"\"") + "\""; } else { return v; } } private String emit(int i) { return emit(String.format("%d", i)); } private String emit(long l) { return emit(String.format("%d", l)); } private String emit(double d) { return emit(String.format("%f", d)); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/000077500000000000000000000000001446271450100226765ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java000066400000000000000000000075051446271450100301460ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import java.io.*; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.List; class AbstractResourceReader { private final String file; private final String resource; private final String strings; protected AbstractResourceReader(String file, String resource, String strings) { this.file = file; this.resource = resource; this.strings = strings; } /** * Helper method for creating a Reader for the list file. * * @return a correct Reader instance */ protected List getReaders() { if (strings != null) { return Collections.singletonList(new StringReader(strings)); } if (file != null) { try { return Collections.singletonList(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); } catch (FileNotFoundException e) { throw new RuntimeException("ERROR: Could not find resource", e); } } if (resource != null) { Enumeration urls; try { urls = getClass().getClassLoader().getResources( resource.startsWith("/") ? resource.substring(1) : resource ); } catch (IOException e) { throw new RuntimeException("ERROR: While obtaining resource: " + resource, e); } if (urls.hasMoreElements()) { List readers = new ArrayList<>(); URL url = null; try { while (urls.hasMoreElements()) { url = urls.nextElement(); InputStream stream = url.openStream(); readers.add(new InputStreamReader(stream, StandardCharsets.UTF_8)); } } catch (IOException e) { for (Reader r : readers) { try { r.close(); } catch (IOException e1) { // ignore } } throw new RuntimeException("ERROR: While opening resource: " + url, e); } return readers; } else { throw new RuntimeException("ERROR: Unable to find the resource: " + resource); } } throw new IllegalStateException(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/Action.java000066400000000000000000000033531446271450100247620ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.infra.BenchmarkParams; import java.io.Serializable; class Action implements Serializable { private static final long serialVersionUID = -7315320958163363586L; private final BenchmarkParams params; private final ActionMode mode; public Action(BenchmarkParams params, ActionMode mode) { this.params = params; this.mode = mode; } public ActionMode getMode() { return mode; } public BenchmarkParams getParams() { return params; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/ActionMode.java000066400000000000000000000036021446271450100255640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; enum ActionMode { /** * No action. */ UNDEF(false, false), /** * Do warmup only. */ WARMUP(true, false), /** * Do measurement only. */ MEASUREMENT(false, true), /** * Do both warmup and measurement */ WARMUP_MEASUREMENT(true, true), ; private final boolean doWarmup; private final boolean doMeasurement; ActionMode(boolean doWarmup, boolean doMeasurement) { this.doWarmup = doWarmup; this.doMeasurement = doMeasurement; } public boolean doWarmup() { return doWarmup; } public boolean doMeasurement() { return doMeasurement; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/ActionPlan.java000066400000000000000000000044101446271450100255700ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import java.io.Serializable; import java.util.ArrayList; import java.util.List; public class ActionPlan implements Serializable { private static final long serialVersionUID = 7250784375093638099L; private final List actions; private final ActionType type; public ActionPlan(ActionType type) { this.type = type; this.actions = new ArrayList<>(); } public ActionType getType() { return type; } public void add(Action action) { actions.add(action); } public void mixIn(ActionPlan other) { actions.addAll(other.actions); } public List getActions() { return actions; } public List getMeasurementActions() { List result = new ArrayList<>(); for (Action action : actions) { switch (action.getMode()) { case MEASUREMENT: case WARMUP_MEASUREMENT: result.add(action); break; } } return result; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/ActionType.java000066400000000000000000000024141446271450100256210ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; enum ActionType { EMBEDDED, FORKED, } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java000066400000000000000000000344331446271450100256140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.BenchmarkResultMetaData; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.runner.format.OutputFormat; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.TreeMultimap; import org.openjdk.jmh.util.Utils; import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.TimeUnit; /** * Abstract runner, the base class for Runner and ForkedRunner. */ abstract class BaseRunner { private long projectedTotalTime; private long projectedRunningTime; private long actualRunningTime; private long benchmarkStart; protected final Options options; protected final OutputFormat out; public BaseRunner(Options options, OutputFormat handler) { if (options == null) { throw new IllegalArgumentException("Options is null."); } if (handler == null) { throw new IllegalArgumentException("Handler is null."); } this.options = options; this.out = handler; } protected void runBenchmarksForked(ActionPlan actionPlan, IterationResultAcceptor acceptor) { for (Action action : actionPlan.getActions()) { BenchmarkParams params = action.getParams(); ActionMode mode = action.getMode(); doSingle(params, mode, acceptor); } } protected Multimap runBenchmarksEmbedded(ActionPlan actionPlan) { Multimap results = new TreeMultimap<>(); for (Action action : actionPlan.getActions()) { BenchmarkParams params = action.getParams(); ActionMode mode = action.getMode(); long startTime = System.currentTimeMillis(); out.startBenchmark(params); out.println(""); etaBeforeBenchmark(); out.println("# Fork: N/A, test runs in the host VM"); out.println("# *** WARNING: Non-forked runs may silently omit JVM options, mess up profilers, disable compiler hints, etc. ***"); out.println("# *** WARNING: Use non-forked runs only for debugging purposes, not for actual performance runs. ***"); final List res = new ArrayList<>(); final List mds = new ArrayList<>(); IterationResultAcceptor acceptor = new IterationResultAcceptor() { @Override public void accept(IterationResult iterationData) { res.add(iterationData); } @Override public void acceptMeta(BenchmarkResultMetaData md) { mds.add(md); } }; doSingle(params, mode, acceptor); if (!res.isEmpty()) { BenchmarkResultMetaData md = mds.get(0); if (md != null) { md.adjustStart(startTime); } BenchmarkResult br = new BenchmarkResult(params, res, md); results.put(params, br); out.endBenchmark(br); } etaAfterBenchmark(params); } return results; } private void doSingle(BenchmarkParams params, ActionMode mode, IterationResultAcceptor acceptor) { try { switch (mode) { case WARMUP: { runBenchmark(params, null); out.println(""); break; } case WARMUP_MEASUREMENT: case MEASUREMENT: { runBenchmark(params, acceptor); break; } default: throw new IllegalStateException("Unknown mode: " + mode); } } catch (BenchmarkException be) { out.println(""); out.println(""); for (Throwable cause : be.getSuppressed()) { out.println(Utils.throwableToString(cause)); } out.println(""); if (options.shouldFailOnError().orElse(Defaults.FAIL_ON_ERROR)) { throw be; } } } protected void etaAfterBenchmark(BenchmarkParams params) { long current = System.nanoTime(); projectedRunningTime += estimateTimeSingleFork(params); actualRunningTime += (current - benchmarkStart); benchmarkStart = current; } protected void etaBeforeBenchmarks(Collection plans) { projectedTotalTime = 0; for (ActionPlan plan : plans) { for (Action act : plan.getActions()) { BenchmarkParams params = act.getParams(); projectedTotalTime += (Math.max(1, params.getForks()) + params.getWarmupForks()) * estimateTimeSingleFork(params); } } } private long estimateTimeSingleFork(BenchmarkParams params) { IterationParams wp = params.getWarmup(); IterationParams mp = params.getMeasurement(); long estimatedTime; if (params.getMode() == Mode.SingleShotTime) { // No way to tell how long it will execute, // guess anything, and let ETA compensation to catch up. estimatedTime = (wp.getCount() + mp.getCount()) * TimeUnit.MILLISECONDS.toNanos(1); } else { estimatedTime = (wp.getCount() * wp.getTime().convertTo(TimeUnit.NANOSECONDS) + mp.getCount() * mp.getTime().convertTo(TimeUnit.NANOSECONDS)); } return estimatedTime; } protected void etaBeforeBenchmark() { if (benchmarkStart == 0) { benchmarkStart = System.nanoTime(); } long totalETA; double partsDone = 1.0D * projectedRunningTime / projectedTotalTime; if (partsDone != 0) { totalETA = (long) (actualRunningTime * (1.0D / partsDone - 1)); } else { totalETA = projectedTotalTime; } out.println(String.format("# Run progress: %.2f%% complete, ETA %s", partsDone * 100, formatDuration(totalETA))); } protected void etaAfterBenchmarks() { out.println(String.format("# Run complete. Total time: %s", formatDuration(actualRunningTime))); out.println(""); } private String formatDuration(long nanos) { long days = TimeUnit.NANOSECONDS.toDays(nanos); nanos -= days * TimeUnit.DAYS.toNanos(1); long hrs = TimeUnit.NANOSECONDS.toHours(nanos); nanos -= hrs * TimeUnit.HOURS.toNanos(1); long mins = TimeUnit.NANOSECONDS.toMinutes(nanos); nanos -= mins * TimeUnit.MINUTES.toNanos(1); long secs = TimeUnit.NANOSECONDS.toSeconds(nanos); return String.format("%s%02d:%02d:%02d", (days > 0) ? days + " days, " : "", hrs, mins, secs); } void runBenchmark(BenchmarkParams benchParams, IterationResultAcceptor acceptor) { BenchmarkHandler handler = null; try { handler = new BenchmarkHandler(out, options, benchParams); runBenchmark(benchParams, handler, acceptor); } catch (BenchmarkException be) { throw be; } catch (Throwable ex) { throw new BenchmarkException(ex); } finally { if (handler != null) { handler.shutdown(); } } } protected void runBenchmark(BenchmarkParams benchParams, BenchmarkHandler handler, IterationResultAcceptor acceptor) { long warmupTime = System.currentTimeMillis(); long allWarmup = 0; long allMeasurement = 0; // warmup IterationParams wp = benchParams.getWarmup(); for (int i = 1; i <= wp.getCount(); i++) { // will run system gc if we should if (runSystemGC()) { out.verbosePrintln("System.gc() executed"); } out.iteration(benchParams, wp, i); boolean isFirstIteration = (i == 1); boolean isLastIteration = (benchParams.getMeasurement().getCount() == 0); IterationResult ir = handler.runIteration(benchParams, wp, isFirstIteration, isLastIteration); out.iterationResult(benchParams, wp, i, ir); allWarmup += ir.getMetadata().getAllOps(); } long measurementTime = System.currentTimeMillis(); // measurement IterationParams mp = benchParams.getMeasurement(); for (int i = 1; i <= mp.getCount(); i++) { // will run system gc if we should if (runSystemGC()) { out.verbosePrintln("System.gc() executed"); } // run benchmark iteration out.iteration(benchParams, mp, i); boolean isFirstIteration = (benchParams.getWarmup().getCount() == 0) && (i == 1); boolean isLastIteration = (i == mp.getCount()); IterationResult ir = handler.runIteration(benchParams, mp, isFirstIteration, isLastIteration); out.iterationResult(benchParams, mp, i, ir); allMeasurement += ir.getMetadata().getAllOps(); if (acceptor != null) { acceptor.accept(ir); } } long stopTime = System.currentTimeMillis(); BenchmarkResultMetaData md = new BenchmarkResultMetaData( warmupTime, measurementTime, stopTime, allWarmup, allMeasurement); if (acceptor != null) { acceptor.acceptMeta(md); } } /** * Execute System.gc() if we the System.gc option is set. * * @return true if we did */ public boolean runSystemGC() { if (options.shouldDoGC().orElse(Defaults.DO_GC)) { List enabledBeans = new ArrayList<>(); long beforeGcCount = 0; for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { long count = bean.getCollectionCount(); if (count != -1) { enabledBeans.add(bean); } } for (GarbageCollectorMXBean bean : enabledBeans) { beforeGcCount += bean.getCollectionCount(); } // Run the GC twice, and force finalization before each GCs. System.runFinalization(); System.gc(); System.runFinalization(); System.gc(); // Now make sure GC actually happened. We have to wait for two things: // a) That at least two collections happened, indicating GC work. // b) That counter updates have not happened for a while, indicating GC work had ceased. // // Note there is an opportunity window for a concurrent GC to happen before the first // System.gc() call, which would get counted towards our GCs. This race is unresolvable // unless we have GC-specific information about the collection cycles, and verify those // were indeed GCs triggered by us. final int MAX_WAIT_MSEC = 20 * 1000; if (enabledBeans.isEmpty()) { out.println("WARNING: MXBeans can not report GC info. System.gc() invoked, pessimistically waiting " + MAX_WAIT_MSEC + " msecs"); try { TimeUnit.MILLISECONDS.sleep(MAX_WAIT_MSEC); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } return true; } boolean gcHappened = false; long start = System.nanoTime(); while (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) < MAX_WAIT_MSEC) { try { TimeUnit.MILLISECONDS.sleep(200); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } long afterGcCount = 0; for (GarbageCollectorMXBean bean : enabledBeans) { afterGcCount += bean.getCollectionCount(); } if (!gcHappened) { if (afterGcCount - beforeGcCount >= 2) { gcHappened = true; } } else { if (afterGcCount == beforeGcCount) { // Stable! return true; } beforeGcCount = afterGcCount; } } if (gcHappened) { out.println("WARNING: System.gc() was invoked but unable to wait while GC stopped, is GC too asynchronous?"); } else { out.println("WARNING: System.gc() was invoked but couldn't detect a GC occurring, is System.gc() disabled?"); } return false; } return false; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java000066400000000000000000000036051446271450100273160ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import java.util.Collection; import java.util.Collections; /** * Internal exception in JMH. Always wraps the real cause. */ public class BenchmarkException extends RuntimeException { private static final long serialVersionUID = 4064666042830679837L; public BenchmarkException(Throwable ex) { this("Benchmark error", Collections.singleton(ex)); } public BenchmarkException(String msg, Collection errors) { super(msg); for (Throwable err : errors) { if (err != null) { addSuppressed(err); } } } @Override public Throwable getCause() { return null; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java000066400000000000000000000526331446271450100267420ustar00rootroot00000000000000/* * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.Control; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.infra.ThreadParams; import org.openjdk.jmh.profile.InternalProfiler; import org.openjdk.jmh.profile.ProfilerFactory; import org.openjdk.jmh.results.*; import org.openjdk.jmh.runner.format.OutputFormat; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.ClassUtils; import org.openjdk.jmh.util.Utils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; import java.util.concurrent.*; /** * Base class for all benchmarks handlers. */ class BenchmarkHandler { /** * Thread-pool for threads executing the benchmark tasks */ private final ExecutorService executor; private final CyclicBarrier workerDataBarrier; private final ConcurrentMap workerData; private final BlockingQueue unusedWorkerData; private final BlockingQueue tps; private final OutputFormat out; private final List profilers; private final List profilersRev; private final Class clazz; private final Method method; public BenchmarkHandler(OutputFormat out, Options options, BenchmarkParams executionParams) { String target = executionParams.generatedBenchmark(); int lastDot = target.lastIndexOf('.'); clazz = ClassUtils.loadClass(target.substring(0, lastDot)); method = BenchmarkHandler.findBenchmarkMethod(clazz, target.substring(lastDot + 1)); profilers = ProfilerFactory.getSupportedInternal(options.getProfilers()); profilersRev = new ArrayList<>(profilers); Collections.reverse(profilersRev); int threads = executionParams.getThreads(); tps = new ArrayBlockingQueue<>(threads); tps.addAll(distributeThreads(threads, executionParams.getThreadGroups())); workerDataBarrier = new CyclicBarrier(threads, this::captureUnusedWorkerData); workerData = new ConcurrentHashMap<>(); unusedWorkerData = new ArrayBlockingQueue<>(threads); this.out = out; try { executor = EXECUTOR_TYPE.createExecutor(threads, executionParams.getBenchmark()); } catch (Exception e) { throw new IllegalStateException(e); } } static List distributeThreads(int threads, int[] groups) { List result = new ArrayList<>(); int totalGroupThreads = Utils.sum(groups); int totalGroups = (int) Math.ceil(1D * threads / totalGroupThreads); int totalSubgroups = groups.length; int currentGroupThread = 0; int currentSubgroupThread = 0; int currentGroup = 0; int currentSubgroup = 0; for (int t = 0; t < threads; t++) { while (currentSubgroupThread >= groups[currentSubgroup]) { currentSubgroup++; if (currentSubgroup == groups.length) { currentGroup++; currentSubgroup = 0; currentGroupThread = 0; } currentSubgroupThread = 0; } result.add(new ThreadParams( t, threads, currentGroup, totalGroups, currentSubgroup, totalSubgroups, currentGroupThread, totalGroupThreads, currentSubgroupThread, groups[currentSubgroup] ) ); currentGroupThread++; currentSubgroupThread++; } return result; } public static Method findBenchmarkMethod(Class clazz, String methodName) { Method method = null; for (Method m : ClassUtils.enumerateMethods(clazz)) { if (m.getName().equals(methodName)) { if (isValidBenchmarkSignature(m)) { if (method != null) { throw new IllegalArgumentException("Ambiguous methods: \n" + method + "\n and \n" + m + "\n, which one to execute?"); } method = m; } else { throw new IllegalArgumentException("Benchmark parameters do not match the signature contract."); } } } if (method == null) { throw new IllegalArgumentException("No matching methods found in benchmark"); } return method; } /** * checks if method signature is valid benchmark signature, * besited checks if method signature corresponds to benchmark type. * @param m * @return */ private static boolean isValidBenchmarkSignature(Method m) { if (m.getReturnType() != BenchmarkTaskResult.class) { return false; } final Class[] parameterTypes = m.getParameterTypes(); if (parameterTypes.length != 2) { return false; } if (parameterTypes[0] != InfraControl.class) { return false; } if (parameterTypes[1] != ThreadParams.class) { return false; } return true; } private static final ExecutorType EXECUTOR_TYPE = Enum.valueOf(ExecutorType.class, System.getProperty("jmh.executor", ExecutorType.PLATFORM.name())); private enum ExecutorType { /** * Use fixed thread pool with platform threads */ PLATFORM { @Override ExecutorService createExecutor(int maxThreads, String prefix) { return Executors.newFixedThreadPool(maxThreads, WorkerThreadFactories.platformWorkerFactory(prefix)); } @Override boolean stableThreads() { return true; } }, /** * Use fixed thread pool with virtual threads */ VIRTUAL { @Override ExecutorService createExecutor(int maxThreads, String prefix) { return Executors.newFixedThreadPool(maxThreads, WorkerThreadFactories.virtualWorkerFactory(prefix)); } @Override boolean shouldYield() { return true; } }, /** * Use ForkJoinPool */ FJP { @Override ExecutorService createExecutor(int maxThreads, String prefix) { return new ForkJoinPool(maxThreads); } }, /** * Use custom executor */ CUSTOM { @Override ExecutorService createExecutor(int maxThreads, String prefix) throws Exception { String className = System.getProperty("jmh.executor.class"); return (ExecutorService) Class.forName(className).getConstructor(int.class, String.class) .newInstance(maxThreads, prefix); } }, ; abstract ExecutorService createExecutor(int maxThreads, String prefix) throws Exception; /** * @return Executor always reuses the same threads? */ boolean stableThreads() { return false; } /** * @return Executing threads should yield occasionally to guarantee progress? */ boolean shouldYield() { return false; } } protected void startProfilers(BenchmarkParams benchmarkParams, IterationParams iterationParams) { // start profilers for (InternalProfiler prof : profilers) { try { prof.beforeIteration(benchmarkParams, iterationParams); } catch (Throwable ex) { throw new BenchmarkException(ex); } } } protected void stopProfilers(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult iterationResults) { // stop profilers for (InternalProfiler prof : profilersRev) { try { iterationResults.addResults(prof.afterIteration(benchmarkParams, iterationParams, iterationResults)); } catch (Throwable ex) { throw new BenchmarkException(ex); } } } /** * Do required shutdown actions. */ public void shutdown() { // No transient data is shared between benchmarks, purge it. workerData.clear(); if (executor == null) { return; } while (true) { executor.shutdown(); try { if (executor.awaitTermination(10, TimeUnit.SECONDS)) { return; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } out.println("Failed to stop executor service " + executor + ", trying again; check for the unaccounted running threads"); } } /** * Runs an iteration on the handled benchmark. * * @param benchmarkParams Benchmark parameters * @param params Iteration parameters * @param isFirstIteration Should this iteration considered to be the first * @param isLastIteration Should this iteration considered to be the last * @return IterationResult */ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationParams params, boolean isFirstIteration, boolean isLastIteration) { int numThreads = benchmarkParams.getThreads(); TimeValue runtime = params.getTime(); CountDownLatch preSetupBarrier = new CountDownLatch(numThreads); CountDownLatch preTearDownBarrier = new CountDownLatch(numThreads); // result object to accumulate the results in List iterationResults = new ArrayList<>(); InfraControl control = new InfraControl(benchmarkParams, params, preSetupBarrier, preTearDownBarrier, isFirstIteration, isLastIteration, EXECUTOR_TYPE.shouldYield(), new Control()); // preparing the worker runnables BenchmarkTask[] runners = new BenchmarkTask[numThreads]; for (int i = 0; i < runners.length; i++) { runners[i] = new BenchmarkTask(control); } long waitDeadline = System.nanoTime() + benchmarkParams.getTimeout().convertTo(TimeUnit.NANOSECONDS); // profilers start way before the workload starts to capture // the edge behaviors. startProfilers(benchmarkParams, params); // submit tasks to threadpool List> completed = new ArrayList<>(); CompletionService srv = new ExecutorCompletionService<>(executor); for (BenchmarkTask runner : runners) { srv.submit(runner); } // wait for all workers to transit to measurement control.awaitWarmupReady(); // wait for the iteration time to expire switch (benchmarkParams.getMode()) { case SingleShotTime: // don't wait here, block on timed result Future break; default: try { Future failing = srv.poll(runtime.convertTo(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS); if (failing != null) { // Oops, some task has exited prematurely, without isDone check. // Must be an exception. Record the failing result, and lift the // timeout deadline: we care only to exit as fast as possible now. completed.add(failing); waitDeadline = System.nanoTime(); } } catch (InterruptedException e) { // regardless... } } // now we communicate all worker threads should stop control.announceDone(); // wait for all workers to transit to teardown control.awaitWarmdownReady(); // Wait for the result, handling timeouts int interrupts = 0; while (completed.size() < numThreads) { try { long waitFor = Math.max(TimeUnit.MILLISECONDS.toNanos(100), waitDeadline - System.nanoTime()); Future fr = srv.poll(waitFor, TimeUnit.NANOSECONDS); if (fr == null) { // We are in the timeout mode now, kick all the still running threads. for (BenchmarkTask task : runners) { Thread runner = task.runner; if (runner != null) { runner.interrupt(); } } interrupts++; } else { completed.add(fr); } } catch (InterruptedException ex) { throw new BenchmarkException(ex); } } if (interrupts > 0) { out.print("(benchmark timed out, interrupted " + interrupts + " times) "); } // Process the results: we get here after all worker threads have quit, // either normally or abnormally. This means, Future.get() would never block. long allOps = 0; long measuredOps = 0; List errors = new ArrayList<>(); for (Future fr : completed) { try { BenchmarkTaskResult btr = fr.get(); iterationResults.addAll(btr.getResults()); allOps += btr.getAllOps(); measuredOps += btr.getMeasuredOps(); } catch (ExecutionException ex) { // Unwrap at most three exceptions through benchmark-thrown exception: // ExecutionException -> Throwable-wrapper -> InvocationTargetException // // Infrastructural exceptions come with shorter causal chains. Throwable cause = ex; for (int c = 0; (c < 3) && (cause.getCause() != null); c++) { cause = cause.getCause(); } // record exception, unless it is the assist exception if (!(cause instanceof FailureAssistException)) { errors.add(cause); } } catch (InterruptedException ex) { // cannot happen here, Future.get() should never block. throw new BenchmarkException(ex); } } IterationResult result = new IterationResult(benchmarkParams, params, new IterationResultMetaData(allOps, measuredOps)); result.addResults(iterationResults); // profilers stop when after all threads are confirmed to be // finished to capture the edge behaviors; or, on a failure path stopProfilers(benchmarkParams, params, result); if (!errors.isEmpty()) { throw new BenchmarkException("Benchmark error during the run", errors); } return result; } private WorkerData getWorkerData(Thread worker) throws Exception { // See if there is a good worker data for us already, use it. WorkerData wd = workerData.remove(worker); // Wait for all threads to roll to this synchronization point. // If there is any thread without assignment, the barrier action // would dump the unused worker data for claiming. workerDataBarrier.await(); if (wd == null) { // Odd mode, no worker task recorded for the thread. Pull the worker data // from the unused queue. This can only happen with executors with unstable threads. if (EXECUTOR_TYPE.stableThreads()) { throw new IllegalStateException("Worker data assignment failed for executor with stable threads"); } wd = unusedWorkerData.poll(); if (wd == null) { throw new IllegalStateException("Cannot get another thread working data"); } } WorkerData exist = workerData.put(worker, wd); if (exist != null) { throw new IllegalStateException("Duplicate thread data"); } return wd; } private void captureUnusedWorkerData() { unusedWorkerData.addAll(workerData.values()); workerData.clear(); } private WorkerData newWorkerData(Thread worker) { try { Object o = clazz.getConstructor().newInstance(); ThreadParams t = tps.poll(); if (t == null) { throw new IllegalStateException("Cannot get another thread params"); } WorkerData wd = new WorkerData(o, t); WorkerData exist = workerData.put(worker, wd); if (exist != null) { throw new IllegalStateException("Duplicate thread data"); } return wd; } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new RuntimeException("Class " + clazz.getName() + " instantiation error ", e); } } /** * Worker body. */ class BenchmarkTask implements Callable { private volatile Thread runner; private final InfraControl control; BenchmarkTask(InfraControl control) { this.control = control; } @Override public BenchmarkTaskResult call() throws Exception { try { // bind the executor thread runner = Thread.currentThread(); // Clear the interruption status for the thread before going into the infra. // Normally, the interrupts would be cleared at the end of benchmark, but // there is a tiny window when harness could deliver another interrupt after // we left. boolean unused = Thread.interrupted(); // poll the current data, or instantiate in this thread, if needed WorkerData wd = control.firstIteration ? newWorkerData(runner) : getWorkerData(runner); return (BenchmarkTaskResult) method.invoke(wd.instance, control, wd.params); } catch (Throwable e) { // about to fail the iteration; // notify other threads we have failed control.isFailing = true; // compensate for missed sync-iteration latches, we don't care about that anymore control.preSetupForce(); control.preTearDownForce(); if (control.benchmarkParams.shouldSynchIterations()) { try { control.announceWarmupReady(); } catch (Exception e1) { // more threads than expected } try { control.announceWarmdownReady(); } catch (Exception e1) { // more threads than expected } } throw new Exception(e); // wrapping Throwable } finally { // unbind the executor thread runner = null; // Clear the interruption status for the thread after leaving the benchmark method. // If any InterruptedExceptions happened, they should have been handled by now. // This prepares the runner thread for another iteration. boolean unused = Thread.interrupted(); } } } /** * Handles thread-local data for each worker that should not change * between the iterations. */ private static class WorkerData { /** * Synthetic benchmark instance, which holds the benchmark metadata. * Expected to be touched by a single thread only. */ final Object instance; /** * Thread parameters. Among other things, holds the thread's place * in group distribution, and thus should be the same for a given thread. */ final ThreadParams params; public WorkerData(Object instance, ThreadParams params) { this.instance = instance; this.params = params; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java000066400000000000000000000150721446271450100262740ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.runner.format.OutputFormat; import org.openjdk.jmh.util.FileUtils; import java.io.*; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Pattern; /** * Helper class for listing micro benchmarks. */ public class BenchmarkList extends AbstractResourceReader { /** Location of the pre-compiled list of micro benchmarks */ public static final String BENCHMARK_LIST = "/META-INF/BenchmarkList"; public static BenchmarkList defaultList() { return fromResource(BENCHMARK_LIST); } public static BenchmarkList fromFile(String file) { return new BenchmarkList(file, null, null); } public static BenchmarkList fromResource(String resource) { return new BenchmarkList(null, resource, null); } public static BenchmarkList fromString(String strings) { return new BenchmarkList(null, null, strings); } public static List readBenchmarkList(InputStream stream) throws IOException { try (Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { List entries = new ArrayList<>(); for (String line : FileUtils.readAllLines(reader)) { BenchmarkListEntry ble = new BenchmarkListEntry(line); entries.add(ble); } return entries; } } public static void writeBenchmarkList(OutputStream stream, Collection entries) { try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(stream, StandardCharsets.UTF_8))) { List sorted = new ArrayList<>(entries); Collections.sort(sorted); for (BenchmarkListEntry entry : sorted) { writer.println(entry.toLine()); } } } private BenchmarkList(String file, String resource, String strings) { super(file, resource, strings); } /** * Gets all micro benchmarks from the list, sorted. * * @param out Output the messages here * @param excludes List of regexps to match excludes against * @return A list of all benchmarks, excluding matched */ public Set getAll(OutputFormat out, List excludes) { return find(out, Collections.singletonList(".*"), excludes); } /** * Gets all the micro benchmarks that matches the given regexp, sorted. * * @param out Output the messages here * @param includes List of regexps to match against * @param excludes List of regexps to match excludes against * @return Names of all micro benchmarks in the list that matches includes and NOT matching excludes */ public SortedSet find(OutputFormat out, List includes, List excludes) { // assume we match all benchmarks when include is empty List regexps = new ArrayList<>(includes); if (regexps.isEmpty()) { regexps.add(Defaults.INCLUDE_BENCHMARKS); } // compile all patterns List includePatterns = new ArrayList<>(regexps.size()); for (String regexp : regexps) { includePatterns.add(Pattern.compile(regexp)); } List excludePatterns = new ArrayList<>(excludes.size()); for (String regexp : excludes) { excludePatterns.add(Pattern.compile(regexp)); } // find all benchmarks containing pattern SortedSet result = new TreeSet<>(); try { for (Reader r : getReaders()) { try (BufferedReader reader = new BufferedReader(r)) { for (String line = reader.readLine(); line != null; line = reader.readLine()) { if (line.startsWith("#")) { continue; } if (line.trim().isEmpty()) { continue; } BenchmarkListEntry br = new BenchmarkListEntry(line); for (Pattern pattern : includePatterns) { if (pattern.matcher(br.getUsername()).find()) { boolean exclude = false; // excludes override for (Pattern excludePattern : excludePatterns) { if (excludePattern.matcher(br.getUsername()).find()) { out.verbosePrintln("Excluding " + br.getUsername() + ", matches " + excludePattern); exclude = true; break; } } if (!exclude) { result.add(br); } break; } else { out.verbosePrintln("Excluding: " + br.getUsername() + ", does not match " + pattern); } } } } } } catch (IOException ex) { throw new RuntimeException("Error reading benchmark list", ex); } return result; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java000066400000000000000000000305011446271450100273100ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Optional; import org.openjdk.jmh.util.lines.TestLineReader; import org.openjdk.jmh.util.lines.TestLineWriter; import java.util.Arrays; import java.util.Collection; import java.util.Map; import java.util.Objects; import java.util.concurrent.TimeUnit; public class BenchmarkListEntry implements Comparable { private final String userClassQName; private final String generatedClassQName; private final String method; private final Mode mode; private final int[] threadGroups; private final Optional> threadGroupLabels; private final Optional threads; private final Optional warmupIterations; private final Optional warmupTime; private final Optional warmupBatchSize; private final Optional measurementIterations; private final Optional measurementTime; private final Optional measurementBatchSize; private final Optional forks; private final Optional warmupForks; private final Optional jvm; private final Optional> jvmArgs; private final Optional> jvmArgsPrepend; private final Optional> jvmArgsAppend; private final Optional> params; private final Optional tu; private final Optional opsPerInvocation; private final Optional timeout; private WorkloadParams workloadParams; public BenchmarkListEntry(String userClassQName, String generatedClassQName, String method, Mode mode, Optional threads, int[] threadGroups, Optional> threadGroupLabels, Optional warmupIterations, Optional warmupTime, Optional warmupBatchSize, Optional measurementIterations, Optional measurementTime, Optional measurementBatchSize, Optional forks, Optional warmupForks, Optional jvm, Optional> jvmArgs, Optional> jvmArgsPrepend, Optional> jvmArgsAppend, Optional> params, Optional tu, Optional opsPerInv, Optional timeout) { this.userClassQName = userClassQName; this.generatedClassQName = generatedClassQName; this.method = method; this.mode = mode; this.threadGroups = threadGroups; this.threads = threads; this.threadGroupLabels = threadGroupLabels; this.warmupIterations = warmupIterations; this.warmupTime = warmupTime; this.warmupBatchSize = warmupBatchSize; this.measurementIterations = measurementIterations; this.measurementTime = measurementTime; this.measurementBatchSize = measurementBatchSize; this.forks = forks; this.warmupForks = warmupForks; this.jvm = jvm; this.jvmArgs = jvmArgs; this.jvmArgsPrepend = jvmArgsPrepend; this.jvmArgsAppend = jvmArgsAppend; this.params = params; this.workloadParams = new WorkloadParams(); this.tu = tu; this.opsPerInvocation = opsPerInv; this.timeout = timeout; } public BenchmarkListEntry(String line) { this.workloadParams = new WorkloadParams(); TestLineReader reader = new TestLineReader(line); if (!reader.isCorrect()) { throw new IllegalStateException("Unable to parse the line: " + line); } this.userClassQName = reader.nextString(); this.generatedClassQName = reader.nextString(); this.method = reader.nextString(); this.mode = Mode.deepValueOf(reader.nextString()); this.threads = reader.nextOptionalInt(); this.threadGroups = reader.nextIntArray(); this.threadGroupLabels = reader.nextOptionalStringCollection(); this.warmupIterations = reader.nextOptionalInt(); this.warmupTime = reader.nextOptionalTimeValue(); this.warmupBatchSize = reader.nextOptionalInt(); this.measurementIterations = reader.nextOptionalInt(); this.measurementTime = reader.nextOptionalTimeValue(); this.measurementBatchSize = reader.nextOptionalInt(); this.forks = reader.nextOptionalInt(); this.warmupForks = reader.nextOptionalInt(); this.jvm = reader.nextOptionalString(); this.jvmArgs = reader.nextOptionalStringCollection(); this.jvmArgsPrepend = reader.nextOptionalStringCollection(); this.jvmArgsAppend = reader.nextOptionalStringCollection(); this.params = reader.nextOptionalParamCollection(); this.tu = reader.nextOptionalTimeUnit(); this.opsPerInvocation = reader.nextOptionalInt(); this.timeout = reader.nextOptionalTimeValue(); } public String toLine() { TestLineWriter writer = new TestLineWriter(); writer.putString(userClassQName); writer.putString(generatedClassQName); writer.putString(method); writer.putString(mode.toString()); writer.putOptionalInt(threads); writer.putIntArray(threadGroups); writer.putOptionalStringCollection(threadGroupLabels); writer.putOptionalInt(warmupIterations); writer.putOptionalTimeValue(warmupTime); writer.putOptionalInt(warmupBatchSize); writer.putOptionalInt(measurementIterations); writer.putOptionalTimeValue(measurementTime); writer.putOptionalInt(measurementBatchSize); writer.putOptionalInt(forks); writer.putOptionalInt(warmupForks); writer.putOptionalString(jvm); writer.putOptionalStringCollection(jvmArgs); writer.putOptionalStringCollection(jvmArgsPrepend); writer.putOptionalStringCollection(jvmArgsAppend); writer.putOptionalParamCollection(params); writer.putOptionalTimeUnit(tu); writer.putOptionalInt(opsPerInvocation); writer.putOptionalTimeValue(timeout); return writer.toString(); } public BenchmarkListEntry cloneWith(Mode mode) { return new BenchmarkListEntry(userClassQName, generatedClassQName, method, mode, threads, threadGroups, threadGroupLabels, warmupIterations, warmupTime, warmupBatchSize, measurementIterations, measurementTime, measurementBatchSize, forks, warmupForks, jvm, jvmArgs, jvmArgsPrepend, jvmArgsAppend, params, tu, opsPerInvocation, timeout); } public BenchmarkListEntry cloneWith(WorkloadParams p) { BenchmarkListEntry br = new BenchmarkListEntry(userClassQName, generatedClassQName, method, mode, threads, threadGroups, threadGroupLabels, warmupIterations, warmupTime, warmupBatchSize, measurementIterations, measurementTime, measurementBatchSize, forks, warmupForks, jvm, jvmArgs, jvmArgsPrepend, jvmArgsAppend, params, tu, opsPerInvocation, timeout); br.workloadParams = p; return br; } public WorkloadParams getWorkloadParams() { return workloadParams; } @Override public int compareTo(BenchmarkListEntry o) { int v = mode.compareTo(o.mode); if (v != 0) { return v; } int v1 = getUsername().compareTo(o.getUsername()); if (v1 != 0) { return v1; } if (workloadParams == null || o.workloadParams == null) { return 0; } return workloadParams.compareTo(o.workloadParams); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; BenchmarkListEntry record = (BenchmarkListEntry) o; if (mode != record.mode) return false; if (!Objects.equals(workloadParams, record.workloadParams)) return false; if (!Objects.equals(userClassQName, record.userClassQName)) return false; if (!Objects.equals(method, record.method)) return false; return true; } @Override public int hashCode() { int result = userClassQName != null ? userClassQName.hashCode() : 0; result = 31 * result + (method != null ? method.hashCode() : 0); result = 31 * result + (mode != null ? mode.hashCode() : 0); result = 31 * result + (workloadParams != null ? workloadParams.hashCode() : 0); return result; } public String generatedTarget() { return generatedClassQName + "." + method + "_" + mode; } public String getUsername() { return userClassQName + "." + method; } public String getUserClassQName() { return userClassQName; } public Mode getMode() { return mode; } public int[] getThreadGroups() { return Arrays.copyOf(threadGroups, threadGroups.length); } public Optional> getThreadGroupLabels() { return threadGroupLabels; } @Override public String toString() { return "{'" + userClassQName + "." + method + "', " + mode + ", " + workloadParams + "}"; } public Optional getWarmupTime() { return warmupTime; } public Optional getWarmupIterations() { return warmupIterations; } public Optional getWarmupBatchSize() { return warmupBatchSize; } public Optional getMeasurementTime() { return measurementTime; } public Optional getMeasurementIterations() { return measurementIterations; } public Optional getMeasurementBatchSize() { return measurementBatchSize; } public Optional getForks() { return forks; } public Optional getWarmupForks() { return warmupForks; } public Optional getJvm() { return jvm; } public Optional> getJvmArgs() { return jvmArgs; } public Optional> getJvmArgsAppend() { return jvmArgsAppend; } public Optional> getJvmArgsPrepend() { return jvmArgsPrepend; } public Optional getThreads() { return threads; } public Optional> getParams() { return params; } public Optional getTimeUnit() { return tu; } public Optional getOperationsPerInvocation() { return opsPerInvocation; } public Optional getTimeout() { return timeout; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java000066400000000000000000000435311446271450100263270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.Utils; import java.io.*; import java.util.*; public class CompilerHints extends AbstractResourceReader { public static final String LIST = "/META-INF/CompilerHints"; // All OpenJDK/HotSpot VMs are supported static final String[] HINT_COMPATIBLE_JVMS = { "OpenJDK", "HotSpot", "GraalVM" }; // Zing is only compatible from post 5.10.*.* releases static final String JVM_ZING = "Zing"; private static volatile CompilerHints defaultList; private static volatile String hintsFile; private final Set hints; static final String XX_COMPILE_COMMAND_FILE = "-XX:CompileCommandFile="; static final String BLACKHOLE_MODE_NAME = "jmh.blackhole.mode"; static final String BLACKHOLE_AUTODETECT_NAME = "jmh.blackhole.autoDetect"; static final String BLACKHOLE_DEBUG_NAME = "jmh.blackhole.debug"; static final String COMPILER_HINTS_MODE = "jmh.compilerhints.mode"; static final boolean BLACKHOLE_MODE_AUTODETECT = Boolean.parseBoolean(System.getProperty(BLACKHOLE_AUTODETECT_NAME, "true")); static final boolean BLACKHOLE_MODE_DEBUG = Boolean.parseBoolean(System.getProperty(BLACKHOLE_DEBUG_NAME, "false")); public static CompilerHints defaultList() { if (defaultList == null) { defaultList = fromResource(LIST); } return defaultList; } public static String hintsFile() { if (hintsFile == null) { try { final Set defaultHints = defaultList().get(); List hints = new ArrayList<>(defaultHints.size() + 2); hints.add("quiet"); // Set up Blackholes BlackholeMode bhMode = blackholeMode(); hints.add("inline,org/openjdk/jmh/infra/Blackhole.consume"); hints.add("dontinline,org/openjdk/jmh/infra/Blackhole.consumeCPU"); if (bhMode.shouldBlackhole()) { hints.add("blackhole,org/openjdk/jmh/infra/Blackhole.consumeCompiler"); } if (bhMode.shouldNotInline()) { hints.add("dontinline,org/openjdk/jmh/infra/Blackhole.consumeFull"); } hints.addAll(defaultHints); hintsFile = FileUtils.createTempFileWithLines("compilecommand", hints); } catch (IOException e) { throw new IllegalStateException("Error creating compiler hints file", e); } } return hintsFile; } public static CompilerHints fromResource(String resource) { return new CompilerHints(null, resource); } public static CompilerHints fromFile(String file) { return new CompilerHints(file, null); } private CompilerHints(String file, String resource) { super(file, resource, null); hints = Collections.unmodifiableSet(read()); } public enum CompilerHintsSelect { FORCE_ON("Forced on", false, true), FORCE_OFF("Forced off", false, false), AUTO_ON("Automatically enabled", true, true), AUTO_OFF("Automatically disabled", true, false); private final String desc; private final boolean auto; private final boolean enabled; CompilerHintsSelect(String desc, boolean auto, boolean enabled) { this.desc = desc; this.auto = auto; this.enabled = enabled; } public String desc() { return desc; } public boolean isAuto() { return auto; } public boolean isEnabled() { return enabled; } } static CompilerHintsSelect compilerHintsSelect; public static CompilerHintsSelect compilerHintsSelect() { if (compilerHintsSelect == null) { compilerHintsSelect = checkCompilerHintsState(); } return compilerHintsSelect; } static void resetCompilerHintsSelect() { // only used by tests compilerHintsSelect = null; } private static boolean compilerHintsEnabled() { return compilerHintsSelect().isEnabled(); } /** * FIXME (low priority): check if supplied JVM is hint compatible. This test is applied to the Runner VM, * not the Forked and may therefore be wrong if the forked VM is not the same JVM */ private static CompilerHintsSelect checkCompilerHintsState() { String propMode = System.getProperty(COMPILER_HINTS_MODE); if (propMode != null) { CompilerHintsSelect forced; try { forced = CompilerHintsSelect.valueOf(propMode); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(COMPILER_HINTS_MODE + " should be set to FORCE_ON or FORCE_OFF", e); } if (forced.isAuto()) { throw new IllegalArgumentException(COMPILER_HINTS_MODE + " should be set to FORCE_ON or FORCE_OFF"); } return forced; } String name = System.getProperty("java.vm.name"); for (String vmName : HINT_COMPATIBLE_JVMS) { if (name.contains(vmName)) { return CompilerHintsSelect.AUTO_ON; } } if (name.contains(JVM_ZING)) { // 1.*.0-zing_*.*.*.* String version = System.getProperty("java.version"); try { // get the version digits String[] versionDigits = version.substring(version.indexOf('_') + 1).split("\\."); if (Integer.parseInt(versionDigits[0]) > 5) { return CompilerHintsSelect.AUTO_ON; } else if (Integer.parseInt(versionDigits[0]) == 5 && Integer.parseInt(versionDigits[1]) >= 10) { return CompilerHintsSelect.AUTO_ON; } } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { // unknown Zing version format System.err.println("ERROR: Zing version format does not match 1.*.0-zing_*.*.*.*"); } } return CompilerHintsSelect.AUTO_OFF; } public Set get() { return hints; } private Set read() { Set result = new TreeSet<>(); try { for (Reader r : getReaders()) { try (BufferedReader reader = new BufferedReader(r)) { for (String line = reader.readLine(); line != null; line = reader.readLine()) { if (line.startsWith("#")) { continue; } if (line.trim().isEmpty()) { continue; } result.add(line); } } } } catch (IOException ex) { throw new RuntimeException("Error reading compiler hints", ex); } return result; } /** * @param command command arguments list * @return the compiler hint files specified by the command */ public static List getCompileCommandFiles(List command){ List compileCommandFiles = new ArrayList<>(); for (String cmdLineWord : command) { if (cmdLineWord.startsWith(XX_COMPILE_COMMAND_FILE)) { compileCommandFiles.add(cmdLineWord.substring(XX_COMPILE_COMMAND_FILE.length())); } } return compileCommandFiles; } /** * We need to generate a compiler hints file such that it includes: *
    *
  • No compile command files are specified and no .hotspotrc file is available, then do JMH hints only *
  • No compile command files are specified and .hotspotrc file is available, then do JMH hints + .hotspotrc *
  • 1 to N compile command files are specified, then do JMH hints + all specified hints in files *
*

This is a departure from default JVM behavior as the JVM would normally just take the last hints file and ignore * the rest. * * @param command all -XX:CompileCommandLine args will be removed and a merged file will be set */ public static void addCompilerHints(List command) { if (compilerHintsSelect() == CompilerHintsSelect.AUTO_OFF) { System.err.println("WARNING: Not a HotSpot compiler command compatible VM (\"" + System.getProperty("java.vm.name") + "-" + System.getProperty("java.version") + "\"), compiler hints are disabled."); } if (!compilerHintsEnabled()) { return; } List hintFiles = new ArrayList<>(); hintFiles.add(hintsFile()); removeCompileCommandFiles(command, hintFiles); if (hintFiles.size() == 1) { File hotspotCompilerFile = new File(".hotspot_compiler"); if (hotspotCompilerFile.exists()) { hintFiles.add(hotspotCompilerFile.getAbsolutePath()); } } if (blackholeMode() == BlackholeMode.COMPILER) { command.add("-XX:+UnlockDiagnosticVMOptions"); command.add("-XX:+UnlockExperimentalVMOptions"); command.add("-DcompilerBlackholesEnabled=true"); } command.add(CompilerHints.XX_COMPILE_COMMAND_FILE + mergeHintFiles(hintFiles)); } /** * @param command the compile command file options will be removed from this command * @param compileCommandFiles the compiler hint files specified by the command will be added to this list */ private static void removeCompileCommandFiles(List command, List compileCommandFiles){ Iterator iterator = command.iterator(); while (iterator.hasNext()) { String cmdLineWord = iterator.next(); if(cmdLineWord.startsWith(XX_COMPILE_COMMAND_FILE)) { compileCommandFiles.add(cmdLineWord.substring(XX_COMPILE_COMMAND_FILE.length())); iterator.remove(); } } } private static String mergeHintFiles(List compileCommandFiles) { if (compileCommandFiles.size() == 1) { return compileCommandFiles.get(0); } try { Set hints = new TreeSet<>(); for(String file : compileCommandFiles) { hints.addAll(fromFile(file).get()); } return FileUtils.createTempFileWithLines("compilecommand", hints); } catch (IOException e) { throw new IllegalStateException("Error merging compiler hints files", e); } } private static BlackholeMode blackholeMode; private static BlackholeSelect blackholeSelect; private static BlackholeMode blackholeMode() { if (blackholeMode != null) { return blackholeMode; } // Forced mode takes precedence. String propMode = System.getProperty(BLACKHOLE_MODE_NAME); if (propMode != null) { try { blackholeMode = BlackholeMode.valueOf(propMode); blackholeSelect = BlackholeSelect.FORCED; // Extra safety: If user requested compiler blackholes, check // if they are available and fail otherwise. if (blackholeMode.shouldBlackhole() && !compilerBlackholesAvailable()) { throw new IllegalStateException("Compiler Blackholes are not available in current VM"); } return blackholeMode; } catch (IllegalArgumentException iae) { throw new IllegalStateException("Unknown Blackhole mode: " + propMode); } } // Try to autodetect blackhole mode, fail if not available if (BLACKHOLE_MODE_AUTODETECT) { if (compilerBlackholesAvailable()) { blackholeMode = BlackholeMode.COMPILER; } else { blackholeMode = BlackholeMode.FULL_DONTINLINE; } blackholeSelect = BlackholeSelect.AUTO; return blackholeMode; } // Not forced, not auto-detected, fallback blackholeMode = BlackholeMode.FULL_DONTINLINE; blackholeSelect = BlackholeSelect.FALLBACK; return blackholeMode; } private static BlackholeSelect blackholeSelect() { blackholeMode(); return blackholeSelect; } private enum BlackholeMode { COMPILER(true, false, "compiler"), FULL_DONTINLINE(false, true, "full + dont-inline hint"), FULL(false, false, "full"), ; private final boolean shouldBlackhole; private final boolean shouldNotInline; private final String desc; BlackholeMode(boolean shouldBlackhole, boolean shouldNotInline, String desc) { this.shouldBlackhole = shouldBlackhole; this.shouldNotInline = shouldNotInline; this.desc = desc; } public boolean shouldBlackhole() { return shouldBlackhole; } public boolean shouldNotInline() { return shouldNotInline; } public String desc() { return desc; } } private enum BlackholeSelect { AUTO("auto-detected, use -D" + BLACKHOLE_AUTODETECT_NAME + "=false to disable"), FALLBACK("fallback, use -D" + BLACKHOLE_MODE_NAME + " to force"), FORCED("forced"), ; final String desc; BlackholeSelect(String desc) { this.desc = desc; } public String desc() { return desc; } } private static boolean compilerBlackholesAvailable() { // Step 1. See if there were any error messages from CompilerOracle { List cmd = new ArrayList<>(); cmd.add(Utils.getCurrentJvm()); cmd.add("-XX:+UnlockExperimentalVMOptions"); cmd.add("-XX:CompileCommand=quiet"); cmd.add("-XX:CompileCommand=blackhole,some/fake/Class.method"); cmd.add("-version"); debug("Blackhole command errors test:"); Collection log = Utils.runWith(cmd); for (String l : log) { debug(l); if (l.contains("CompilerOracle") || l.contains("CompileCommand")) { debug("Found the suspected error line, no compiler blackholes."); return false; } } } // Step 2. See that CompilerOracle accepted the command explicitly { List cmd = new ArrayList<>(); cmd.add(Utils.getCurrentJvm()); cmd.add("-XX:+UnlockExperimentalVMOptions"); cmd.add("-XX:CompileCommand=blackhole,some/fake/Class.method"); cmd.add("-version"); debug("Blackhole command acceptance test:"); Collection log = Utils.runWith(cmd); for (String l : log) { debug(l); if (l.contains("CompilerOracle") || l.contains("CompileCommand")) { debug("Found the acceptance line, compiler blackholes are available."); return true; } } } // Err on the side of the caution: compiler blackholes are not available. debug("Compiler blackholes are not available."); return false; } private static void debug(String msg) { if (BLACKHOLE_MODE_DEBUG) { System.out.println(msg); } } public static void printHints(PrintStream out) { if (!compilerHintsSelect().isAuto()) { out.print("# Compiler hints: " + (compilerHintsEnabled() ? "enabled" : "disabled") + " (" + compilerHintsSelect().desc() + ")"); out.println(); } BlackholeMode mode = blackholeMode(); out.print("# Blackhole mode: " + mode.desc() + " (" + blackholeSelect().desc() + ")"); out.println(); } public static void printWarnings(PrintStream out) { if (blackholeMode() == BlackholeMode.COMPILER) { out.println("NOTE: Current JVM experimentally supports Compiler Blackholes, and they are in use. Please exercise"); out.println("extra caution when trusting the results, look into the generated code to check the benchmark still"); out.println("works, and factor in a small probability of new VM bugs. Additionally, while comparisons between"); out.println("different JVMs are already problematic, the performance difference caused by different Blackhole"); out.println("modes can be very significant. Please make sure you use the consistent Blackhole mode for comparisons."); out.println(); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java000066400000000000000000000107101446271450100253070ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.runner.options.WarmupMode; import java.util.concurrent.TimeUnit; /** * JMH global defaults: these are used when no other values are available. */ public class Defaults { /** * Number of warmup iterations. */ public static final int WARMUP_ITERATIONS = 5; /** * Number of warmup iterations in {@link org.openjdk.jmh.annotations.Mode#SingleShotTime} mode. */ public static final int WARMUP_ITERATIONS_SINGLESHOT = 0; /** * The batch size in warmup mode. */ public static final int WARMUP_BATCHSIZE = 1; /** * The duration of warmup iterations. */ public static final TimeValue WARMUP_TIME = TimeValue.seconds(10); /** * Number of measurement iterations. */ public static final int MEASUREMENT_ITERATIONS = 5; /** * Number of measurement iterations in {@link org.openjdk.jmh.annotations.Mode#SingleShotTime} mode. */ public static final int MEASUREMENT_ITERATIONS_SINGLESHOT = 1; /** * The batch size in measurement mode. */ public static final int MEASUREMENT_BATCHSIZE = 1; /** * The duration of measurement iterations. */ public static final TimeValue MEASUREMENT_TIME = TimeValue.seconds(10); /** * Number of measurement threads. */ public static final int THREADS = 1; /** * Number of forks in which we measure the workload. */ public static final int MEASUREMENT_FORKS = 5; /** * Number of warmup forks we discard. */ public static final int WARMUP_FORKS = 0; /** * Should JMH fail on benchmark error? */ public static final boolean FAIL_ON_ERROR = false; /** * Should JMH synchronize iterations? */ public static final boolean SYNC_ITERATIONS = true; /** * Should JMH do GC between iterations? */ public static final boolean DO_GC = false; /** * The default {@link org.openjdk.jmh.results.format.ResultFormatType} to use. */ public static final ResultFormatType RESULT_FORMAT = ResultFormatType.CSV; /** * Default prefix of the result file. */ public static final String RESULT_FILE_PREFIX = "jmh-result"; /** * Default {@link org.openjdk.jmh.runner.options.WarmupMode}. */ public static final WarmupMode WARMUP_MODE = WarmupMode.INDI; /** * Default {@link org.openjdk.jmh.runner.options.VerboseMode}. */ public static final VerboseMode VERBOSITY = VerboseMode.NORMAL; /** * Default running mode. */ public static final Mode BENCHMARK_MODE = Mode.Throughput; /** * Default output time unit. */ public static final TimeUnit OUTPUT_TIMEUNIT = TimeUnit.SECONDS; /** * Default operations per invocation. */ public static final Integer OPS_PER_INVOCATION = 1; /** * Default timeout. */ public static final TimeValue TIMEOUT = TimeValue.minutes(10); /** * Default benchmarks to include. */ public static final String INCLUDE_BENCHMARKS = ".*"; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/FailureAssistException.java000066400000000000000000000026501446271450100302010ustar00rootroot00000000000000/* * Copyright (c) 2016, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; /** * Thrown by worker threads when they detect other threads have failed. */ public class FailureAssistException extends RuntimeException { private static final long serialVersionUID = -7132741247248095175L; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java000066400000000000000000000214441446271450100255650ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.runner.link.BinaryLinkClient; import org.openjdk.jmh.runner.options.Options; import java.io.IOException; import java.io.PrintStream; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; /** * Main program entry point for forked JVM instance */ class ForkedMain { private static final AtomicBoolean hangupFuse = new AtomicBoolean(); private static final AtomicReference linkRef = new AtomicReference<>(); private static volatile boolean gracefullyFinished; private static volatile Throwable exception; private static volatile PrintStream nakedErr; /** * Application main entry point * * @param argv Command line arguments */ public static void main(String[] argv) { if (argv.length != 2) { throw new IllegalArgumentException("Expected two arguments for forked VM"); } else { // capture nakedErr early, so that hangup/shutdown threads could use it nakedErr = System.err; // arm the hangup thread Runtime.getRuntime().addShutdownHook(new HangupThread()); // init the shutdown thread ShutdownTimeoutThread shutdownThread = new ShutdownTimeoutThread(); try { // This assumes the exact order of arguments: // 1) host name to back-connect // 2) host port to back-connect String hostName = argv[0]; int hostPort = Integer.parseInt(argv[1]); // establish the link to host VM and pull the options BinaryLinkClient link = new BinaryLinkClient(hostName, hostPort); linkRef.set(link); Options options = link.handshake(); // dump outputs into binary link System.setErr(link.getErrStream()); System.setOut(link.getOutStream()); // run! ForkedRunner runner = new ForkedRunner(options, link); runner.run(); gracefullyFinished = true; } catch (Throwable ex) { exception = ex; gracefullyFinished = false; } finally { // arm the shutdown timer shutdownThread.start(); } if (!gracefullyFinished) { System.exit(1); } } } /** * Report our latest status to the host VM, and say goodbye. */ static void hangup() { // hangup fires only once if (!hangupFuse.compareAndSet(false, true)) return; if (!gracefullyFinished) { Throwable ex = exception; if (ex == null) { ex = new IllegalStateException( ""); } String msg = ex.getMessage(); BinaryLinkClient link = linkRef.get(); if (link != null) { try { link.getOutputFormat().println(msg); link.pushException(new BenchmarkException(ex)); } catch (Exception e) { // last resort ex.printStackTrace(nakedErr); } } else { // last resort ex.printStackTrace(nakedErr); } } BinaryLinkClient link = linkRef.getAndSet(null); if (link != null) { try { link.close(); } catch (IOException e) { // swallow } } } /** * Hangup thread will detach us from the host VM properly, in three cases: * - normal shutdown * - shutdown with benchmark exception * - any System.exit call * * The need to intercept System.exit calls is the reason to register ourselves * as the shutdown hook. Additionally, this thread runs only when all non-daemon * threads are stopped, and therefore the stray user threads would be reported * by shutdown timeout thread over still alive binary link. */ private static class HangupThread extends Thread { @Override public void run() { hangup(); } } /** * Shutdown timeout thread will forcefully exit the VM in two cases: * - stray non-daemon thread prevents the VM from exiting * - all user threads have finished, but we are stuck in some shutdown hook or finalizer * * In all other "normal" cases, VM will exit before the timeout expires. */ private static class ShutdownTimeoutThread extends Thread { private static final int TIMEOUT = Integer.getInteger("jmh.shutdownTimeout", 30); private static final int TIMEOUT_STEP = Integer.getInteger("jmh.shutdownTimeout.step", 5); private static final String LINE_SEPARATOR = System.getProperty("line.separator"); public ShutdownTimeoutThread() { setName("JMH-Shutdown-Timeout"); setDaemon(true); } @Override public void run() { long start = System.nanoTime(); long waitMore; do { try { TimeUnit.SECONDS.sleep(TIMEOUT_STEP); } catch (InterruptedException e) { return; } waitMore = TimeUnit.SECONDS.toNanos(TIMEOUT) - (System.nanoTime() - start); String msg = getMessage(waitMore); BinaryLinkClient link = linkRef.get(); if (link != null) { link.getOutputFormat().println(msg); } else { // last resort nakedErr.println(msg); } } while (waitMore > 0); String msg = ""; BinaryLinkClient link = linkRef.get(); if (link != null) { link.getOutputFormat().println(msg); } else { // last resort nakedErr.println(msg); } // aggressively try to hangup, and HALT hangup(); Runtime.getRuntime().halt(0); } private String getMessage(long waitMore) { StringBuilder sb = new StringBuilder(); sb.append(""); sb.append(LINE_SEPARATOR); sb.append(LINE_SEPARATOR); sb.append("Non-finished threads:"); sb.append(LINE_SEPARATOR); sb.append(LINE_SEPARATOR); for (Map.Entry e : Thread.getAllStackTraces().entrySet()) { Thread thread = e.getKey(); StackTraceElement[] els = e.getValue(); if (thread.isDaemon()) continue; if (!thread.isAlive()) continue; sb.append(thread); sb.append(LINE_SEPARATOR); for (StackTraceElement el : els) { sb.append(" at "); sb.append(el); sb.append(LINE_SEPARATOR); } sb.append(LINE_SEPARATOR); } return sb.toString(); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedRunner.java000066400000000000000000000065071446271450100261550ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.results.BenchmarkResultMetaData; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.runner.link.BinaryLinkClient; import org.openjdk.jmh.runner.options.Options; import java.io.IOException; /** * Runner frontend class. Responsible for running micro benchmarks in forked JVM. */ class ForkedRunner extends BaseRunner { private final BinaryLinkClient link; public ForkedRunner(Options options, BinaryLinkClient link) { super(options, link.getOutputFormat()); this.link = link; } public void run() throws IOException, ClassNotFoundException { ActionPlan actionPlan = link.requestPlan(); try { IterationResultAcceptor acceptor = new IterationResultAcceptor() { @Override public void accept(IterationResult iterationData) { try { link.pushResults(iterationData); } catch (IOException e) { // link had probably failed throw new SavedIOException(e); } } @Override public void acceptMeta(BenchmarkResultMetaData md) { try { link.pushResultMetadata(md); } catch (IOException e) { // link had probably failed throw new SavedIOException(e); } } }; runBenchmarksForked(actionPlan, acceptor); } catch (BenchmarkException be) { link.pushException(be); } catch (SavedIOException ioe) { throw ioe.getCause(); } out.flush(); out.close(); } static class SavedIOException extends RuntimeException { private static final long serialVersionUID = -5807039363222713801L; private final IOException e; public SavedIOException(IOException e) { super(e); this.e = e; } public IOException getCause() { return e; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java000066400000000000000000000263671446271450100261570ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.Control; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.util.Utils; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** * The InfraControl logic class. * This is the rendezvous class for benchmark handler and JMH. */ public class InfraControl extends InfraControlL4 { /** * Do the class hierarchy trick to evade false sharing, and check if it's working in runtime. * @see org.openjdk.jmh.infra.Blackhole description for the rationale */ static { Utils.check(InfraControl.class, "isDone", "isFailing"); Utils.check(InfraControl.class, "volatileSpoiler"); Utils.check(InfraControl.class, "preSetup", "preTearDown"); Utils.check(InfraControl.class, "firstIteration"); Utils.check(InfraControl.class, "lastIteration"); Utils.check(InfraControl.class, "shouldYield"); Utils.check(InfraControl.class, "warmupVisited", "warmdownVisited"); Utils.check(InfraControl.class, "warmupShouldWait", "warmdownShouldWait"); Utils.check(InfraControl.class, "warmupDone", "warmdownDone"); Utils.check(InfraControl.class, "benchmarkParams", "iterationParams"); Utils.check(InfraControl.class, "shouldSynchIterations", "threads"); } public InfraControl(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean firstIteration, boolean lastIteration, boolean shouldYield, Control notifyControl) { super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, shouldYield, notifyControl); } /** * @return requested loop duration in milliseconds. */ public long getDuration() { return getDuration(TimeUnit.MILLISECONDS); } /** * @param unit timeunit to use * @return requested loop duration in the requested unit. */ public long getDuration(TimeUnit unit) { return iterationParams.getTime().convertTo(unit); } public void preSetup() { preSetup.countDown(); while (true) { try { preSetup.await(); return; } catch (InterruptedException e) { // Do not accept interrupts here. } } } public void preTearDown() { preTearDown.countDown(); while (true) { try { preTearDown.await(); return; } catch (InterruptedException e) { // Do not accept interrupts here. } } } public void preSetupForce() { preSetup.countDown(); } public void preTearDownForce() { preTearDown.countDown(); } public boolean isLastIteration() { return lastIteration; } public void announceDone() { isDone = true; notifyControl.stopMeasurement = true; } } abstract class InfraControlL0 { private int markerBegin; } abstract class InfraControlL1 extends InfraControlL0 { private boolean p001, p002, p003, p004, p005, p006, p007, p008; private boolean p011, p012, p013, p014, p015, p016, p017, p018; private boolean p021, p022, p023, p024, p025, p026, p027, p028; private boolean p031, p032, p033, p034, p035, p036, p037, p038; private boolean p041, p042, p043, p044, p045, p046, p047, p048; private boolean p051, p052, p053, p054, p055, p056, p057, p058; private boolean p061, p062, p063, p064, p065, p066, p067, p068; private boolean p071, p072, p073, p074, p075, p076, p077, p078; private boolean p101, p102, p103, p104, p105, p106, p107, p108; private boolean p111, p112, p113, p114, p115, p116, p117, p118; private boolean p121, p122, p123, p124, p125, p126, p127, p128; private boolean p131, p132, p133, p134, p135, p136, p137, p138; private boolean p141, p142, p143, p144, p145, p146, p147, p148; private boolean p151, p152, p153, p154, p155, p156, p157, p158; private boolean p161, p162, p163, p164, p165, p166, p167, p168; private boolean p171, p172, p173, p174, p175, p176, p177, p178; } abstract class InfraControlL2 extends InfraControlL1 { /** * Flag that checks for time expiration. * This is specifically the public field, so to spare one virtual call. */ public volatile boolean isDone; /** * Flag that checks for failure experienced by any measurement thread. * This is specifically the public field, so to spare one virtual call. */ public volatile boolean isFailing; public volatile boolean volatileSpoiler; public final CountDownLatch preSetup; public final CountDownLatch preTearDown; public final boolean firstIteration; public final boolean lastIteration; public final boolean shouldYield; public final AtomicInteger warmupVisited, warmdownVisited; public volatile boolean warmupShouldWait, warmdownShouldWait; public final CountDownLatch warmupDone, warmdownDone; public final BenchmarkParams benchmarkParams; public final IterationParams iterationParams; public final Control notifyControl; private final boolean shouldSynchIterations; private final int threads; public InfraControlL2(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean firstIteration, boolean lastIteration, boolean shouldYield, Control notifyControl) { warmupVisited = new AtomicInteger(); warmdownVisited = new AtomicInteger(); warmupDone = new CountDownLatch(1); warmdownDone = new CountDownLatch(1); shouldSynchIterations = benchmarkParams.shouldSynchIterations(); threads = benchmarkParams.getThreads(); warmupShouldWait = shouldSynchIterations; warmdownShouldWait = shouldSynchIterations; this.notifyControl = notifyControl; this.preSetup = preSetup; this.preTearDown = preTearDown; this.firstIteration = firstIteration; this.lastIteration = lastIteration; this.shouldYield = shouldYield; this.benchmarkParams = benchmarkParams; this.iterationParams = iterationParams; } public void announceWarmupReady() { if (!shouldSynchIterations) return; int v = warmupVisited.incrementAndGet(); if (v == threads) { warmupShouldWait = false; warmupDone.countDown(); } if (v > threads) { throw new IllegalStateException("More threads than expected"); } } public void announceWarmdownReady() { if (!shouldSynchIterations) return; int v = warmdownVisited.incrementAndGet(); if (v == threads) { warmdownShouldWait = false; warmdownDone.countDown(); } if (v > threads) { throw new IllegalStateException("More threads than expected"); } } public void awaitWarmupReady() { if (warmupShouldWait) { try { warmupDone.await(); } catch (InterruptedException e) { // ignore } } } public void awaitWarmdownReady() { if (warmdownShouldWait) { try { warmdownDone.await(); } catch (InterruptedException e) { // ignore } } } public String getParam(String name) { String param = benchmarkParams.getParam(name); if (param == null) { throw new IllegalStateException("The value for the parameter \"" + name + "\" is not set."); } return param; } } abstract class InfraControlL3 extends InfraControlL2 { private boolean q001, q002, q003, q004, q005, q006, q007, q008; private boolean q011, q012, q013, q014, q015, q016, q017, q018; private boolean q021, q022, q023, q024, q025, q026, q027, q028; private boolean q031, q032, q033, q034, q035, q036, q037, q038; private boolean q041, q042, q043, q044, q045, q046, q047, q048; private boolean q051, q052, q053, q054, q055, q056, q057, q058; private boolean q061, q062, q063, q064, q065, q066, q067, q068; private boolean q071, q072, q073, q074, q075, q076, q077, q078; private boolean q101, q102, q103, q104, q105, q106, q107, q108; private boolean q111, q112, q113, q114, q115, q116, q117, q118; private boolean q121, q122, q123, q124, q125, q126, q127, q128; private boolean q131, q132, q133, q134, q135, q136, q137, q138; private boolean q141, q142, q143, q144, q145, q146, q147, q148; private boolean q151, q152, q153, q154, q155, q156, q157, q158; private boolean q161, q162, q163, q164, q165, q166, q167, q168; private boolean q171, q172, q173, q174, q175, q176, q177, q178; public InfraControlL3(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean firstIteration, boolean lastIteration, boolean shouldYield, Control notifyControl) { super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, shouldYield, notifyControl); } } abstract class InfraControlL4 extends InfraControlL3 { private int markerEnd; public InfraControlL4(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean firstIteration, boolean lastIteration, boolean shouldYield, Control notifyControl) { super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, shouldYield, notifyControl); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/IterationResultAcceptor.java000066400000000000000000000027171446271450100303660ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.results.BenchmarkResultMetaData; import org.openjdk.jmh.results.IterationResult; interface IterationResultAcceptor { void accept(IterationResult iterationData); void acceptMeta(BenchmarkResultMetaData md); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/IterationType.java000066400000000000000000000024311446271450100263410ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; public enum IterationType { WARMUP, MEASUREMENT, } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/NoBenchmarksException.java000066400000000000000000000027261446271450100300010ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; public class NoBenchmarksException extends RunnerException { private static final long serialVersionUID = 1446854343206595167L; public String toString() { return "No benchmarks to run; check the include/exclude regexps."; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/OutputFormatAdapter.java000066400000000000000000000032371446271450100275200ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.runner.format.OutputFormat; import java.io.IOException; import java.io.OutputStream; class OutputFormatAdapter extends OutputStream { private final OutputFormat out; public OutputFormatAdapter(OutputFormat out) { this.out = out; } @Override public void write(int b) { out.write(b); } @Override public void write(byte[] b) throws IOException { out.write(b); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/PrintPropertiesMain.java000066400000000000000000000041141446271450100275170ustar00rootroot00000000000000/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.util.Utils; import java.io.BufferedOutputStream; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Paths; /** * Main program entry point for exporting the system properties, used for detecting the VM version. */ class PrintPropertiesMain { /** * @param argv Command line arguments */ public static void main(String[] argv) throws Exception { if (argv.length != 1) { throw new IllegalArgumentException("Usage: java " + PrintPropertiesMain.class.getName() + " "); } try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(Paths.get(argv[0])))) { Utils.getRecordedSystemProperties().storeToXML( os, "JMH properties export for target JVM", "UTF-8"); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/ProfilersFailedException.java000066400000000000000000000030321446271450100304700ustar00rootroot00000000000000/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.profile.ProfilerException; public class ProfilersFailedException extends RunnerException { private static final long serialVersionUID = 1446854343206595167L; public ProfilersFailedException(ProfilerException e) { super("Profilers failed to initialize, exiting.", e); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java000066400000000000000000001116021446271450100250130ustar00rootroot00000000000000/* * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.profile.ExternalProfiler; import org.openjdk.jmh.profile.ProfilerException; import org.openjdk.jmh.profile.ProfilerFactory; import org.openjdk.jmh.results.*; import org.openjdk.jmh.results.format.ResultFormatFactory; import org.openjdk.jmh.runner.format.OutputFormat; import org.openjdk.jmh.runner.format.OutputFormatFactory; import org.openjdk.jmh.runner.link.BinaryLinkServer; import org.openjdk.jmh.runner.options.*; import org.openjdk.jmh.util.*; import org.openjdk.jmh.util.Optional; import java.io.*; import java.lang.management.ManagementFactory; import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; import java.nio.file.Files; import java.nio.file.Path; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.jar.*; import java.util.zip.*; /** * Runner executes JMH benchmarks. * *

This is the entry point for JMH Java API.

* *

{@link Runner} is not usually reusable. After you execute any method on the {@link Runner}, you should digest * the results, give up on current {@link Runner}, and instantiate another one. This class may be turned into * static class in future releases.

*/ public class Runner extends BaseRunner { private static final int TAIL_LINES_ON_ERROR = Integer.getInteger("jmh.tailLines", 20); private static final String JMH_LOCK_FILE = System.getProperty("java.io.tmpdir") + "/jmh.lock"; private static final Boolean JMH_LOCK_IGNORE = Boolean.getBoolean("jmh.ignoreLock"); private final BenchmarkList list; private int cpuCount; /** * Create runner with the custom OutputFormat. * * @param options options to use * @param format OutputFormat to use */ public Runner(Options options, OutputFormat format) { super(options, format); this.list = BenchmarkList.defaultList(); } /** * Create Runner with the given options. * This method sets up the {@link org.openjdk.jmh.runner.format.OutputFormat} as * mandated by options. * @param options options to use. */ public Runner(Options options) { this(options, createOutputFormat(options)); } private static OutputFormat createOutputFormat(Options options) { // sadly required here as the check cannot be made before calling this method in constructor if (options == null) { throw new IllegalArgumentException("Options not allowed to be null."); } PrintStream out; if (options.getOutput().hasValue()) { try { out = new PrintStream(options.getOutput().get()); } catch (FileNotFoundException ex) { throw new IllegalStateException(ex); } } else { // Protect the System.out from accidental closing try { out = new UnCloseablePrintStream(System.out, Utils.guessConsoleEncoding()); } catch (UnsupportedEncodingException ex) { throw new IllegalStateException(ex); } } return OutputFormatFactory.createFormatInstance(out, options.verbosity().orElse(Defaults.VERBOSITY)); } /** * Print matching benchmarks into output. */ public void list() { Set benchmarks = list.find(out, options.getIncludes(), options.getExcludes()); out.println("Benchmarks: "); for (BenchmarkListEntry benchmark : benchmarks) { out.println(benchmark.getUsername()); } } /** * Print matching benchmarks with parameters into output. * @param options options to use. */ public void listWithParams(CommandLineOptions options) { Set benchmarks = list.find(out, options.getIncludes(), options.getExcludes()); out.println("Benchmarks: "); for (BenchmarkListEntry benchmark : benchmarks) { out.println(benchmark.getUsername()); Optional> params = benchmark.getParams(); if (params.hasValue()) { for (Map.Entry e : params.get().entrySet()) { String param = e.getKey(); Collection values = options.getParameter(param).orElse(Arrays.asList(e.getValue())); out.println(" param \"" + param + "\" = {" + Utils.join(values, ", ") + "}"); } } } } /** * Shortcut method for the single benchmark execution. * This method is handy when Options describe only the single benchmark to run. * * @return benchmark result * @throws RunnerException if more than one benchmark is found, or no results are returned */ public RunResult runSingle() throws RunnerException { Set benchmarks = list.find(out, options.getIncludes(), options.getExcludes()); if (benchmarks.size() == 1) { Collection values = run(); if (values.size() == 1) { return values.iterator().next(); } else { throw new RunnerException("No results returned"); } } else { if (benchmarks.size() > 1) { throw new RunnerException("More than single benchmark are matching the options: " + benchmarks); } else { throw new NoBenchmarksException(); } } } /** * Run benchmarks. * * @return map of benchmark results * @throws org.openjdk.jmh.runner.RunnerException if something goes wrong */ public Collection run() throws RunnerException { if (JMH_LOCK_IGNORE) { out.println("# WARNING: JMH lock is ignored by user request, make sure no other JMH instances are running"); return internalRun(); } final String tailMsg = " the JMH lock (" + JMH_LOCK_FILE + "), exiting. Use -Djmh.ignoreLock=true to forcefully continue."; File lockFile; try { lockFile = new File(JMH_LOCK_FILE); lockFile.createNewFile(); // Make sure the lock file is world-writeable, otherwise the lock file created by current // user would not work for any other user, always failing the run. lockFile.setWritable(true, false); } catch (IOException e) { throw new RunnerException("ERROR: Unable to create" + tailMsg, e); } try (RandomAccessFile raf = new RandomAccessFile(lockFile, "rw"); FileLock lock = raf.getChannel().tryLock()) { if (lock == null) { // Lock acquisition failed, pretend this was the overlap. throw new OverlappingFileLockException(); } return internalRun(); } catch (OverlappingFileLockException e) { throw new RunnerException("ERROR: Another JMH instance might be running. Unable to acquire" + tailMsg); } catch (IOException e) { throw new RunnerException("ERROR: Unexpected exception while trying to acquire" + tailMsg, e); } } private Collection internalRun() throws RunnerException { Set profilerClasses = new HashSet<>(); ProfilersFailedException failedException = null; for (ProfilerConfig p : options.getProfilers()) { if (!profilerClasses.add(p.getKlass())) { throw new RunnerException("Cannot instantiate the same profiler more than once: " + p.getKlass()); } try { ProfilerFactory.getProfilerOrException(p); } catch (ProfilerException e) { if (failedException == null) { failedException = new ProfilersFailedException(e); } else { failedException.addSuppressed(e); } } } if (failedException != null) { throw failedException; } // If user requested the result file in one way or the other, touch the result file, // and prepare to write it out after the run. String resultFile = null; if (options.getResult().hasValue() || options.getResultFormat().hasValue()) { resultFile = options.getResult().orElse( Defaults.RESULT_FILE_PREFIX + "." + options.getResultFormat().orElse(Defaults.RESULT_FORMAT).toString().toLowerCase() ); try { FileUtils.touch(resultFile); } catch (IOException e) { throw new RunnerException("Can not touch the result file: " + resultFile); } } SortedSet benchmarks = list.find(out, options.getIncludes(), options.getExcludes()); if (benchmarks.isEmpty()) { out.flush(); out.close(); throw new NoBenchmarksException(); } // override the benchmark types; // this may yield new benchmark records if (!options.getBenchModes().isEmpty()) { List newBenchmarks = new ArrayList<>(); for (BenchmarkListEntry br : benchmarks) { for (Mode m : options.getBenchModes()) { newBenchmarks.add(br.cloneWith(m)); } } benchmarks.clear(); benchmarks.addAll(newBenchmarks); } // clone with all the modes { List newBenchmarks = new ArrayList<>(); for (BenchmarkListEntry br : benchmarks) { if (br.getMode() == Mode.All) { for (Mode mode : Mode.values()) { if (mode == Mode.All) continue; newBenchmarks.add(br.cloneWith(mode)); } } else { newBenchmarks.add(br); } } benchmarks.clear(); benchmarks.addAll(newBenchmarks); } // clone with all parameters { List newBenchmarks = new ArrayList<>(); for (BenchmarkListEntry br : benchmarks) { if (br.getParams().hasValue()) { for (WorkloadParams p : explodeAllParams(br)) { newBenchmarks.add(br.cloneWith(p)); } } else { newBenchmarks.add(br); } } benchmarks.clear(); benchmarks.addAll(newBenchmarks); } Collection results = runBenchmarks(benchmarks); // If user requested the result file, write it out. if (resultFile != null) { ResultFormatFactory.getInstance( options.getResultFormat().orElse(Defaults.RESULT_FORMAT), resultFile ).writeOut(results); out.println(""); out.println("Benchmark result is saved to " + resultFile); } out.flush(); out.close(); return results; } private List getActionPlans(Set benchmarks) { ActionPlan base = new ActionPlan(ActionType.FORKED); LinkedHashSet warmupBenches = new LinkedHashSet<>(); List warmupMicrosRegexp = options.getWarmupIncludes(); if (warmupMicrosRegexp != null && !warmupMicrosRegexp.isEmpty()) { warmupBenches.addAll(list.find(out, warmupMicrosRegexp, Collections.emptyList())); } if (options.getWarmupMode().orElse(Defaults.WARMUP_MODE).isBulk()) { warmupBenches.addAll(benchmarks); } for (BenchmarkListEntry wr : warmupBenches) { base.add(newAction(wr, ActionMode.WARMUP)); } ActionPlan embeddedPlan = new ActionPlan(ActionType.EMBEDDED); embeddedPlan.mixIn(base); boolean addEmbedded = false; List result = new ArrayList<>(); for (BenchmarkListEntry br : benchmarks) { BenchmarkParams params = newBenchmarkParams(br, ActionMode.UNDEF); if (params.getForks() <= 0) { if (options.getWarmupMode().orElse(Defaults.WARMUP_MODE).isIndi()) { embeddedPlan.add(newAction(br, ActionMode.WARMUP_MEASUREMENT)); } else { embeddedPlan.add(newAction(br, ActionMode.MEASUREMENT)); } addEmbedded = true; } if (params.getForks() > 0) { ActionPlan r = new ActionPlan(ActionType.FORKED); r.mixIn(base); if (options.getWarmupMode().orElse(Defaults.WARMUP_MODE).isIndi()) { r.add(newAction(br, ActionMode.WARMUP_MEASUREMENT)); } else { r.add(newAction(br, ActionMode.MEASUREMENT)); } result.add(r); } } if (addEmbedded) { result.add(embeddedPlan); } return result; } private Action newAction(BenchmarkListEntry br, ActionMode mode) { return new Action(newBenchmarkParams(br, mode), mode); } private BenchmarkParams newBenchmarkParams(BenchmarkListEntry benchmark, ActionMode mode) { int[] threadGroups = options.getThreadGroups().orElse(benchmark.getThreadGroups()); int threads = options.getThreads().orElse( benchmark.getThreads().orElse( Defaults.THREADS)); if (threads == Threads.MAX) { if (cpuCount == 0) { out.print("# Detecting actual CPU count: "); cpuCount = Utils.figureOutHotCPUs(); out.println(cpuCount + " detected"); } threads = cpuCount; } threads = Utils.roundUp(threads, Utils.sum(threadGroups)); boolean synchIterations = (benchmark.getMode() != Mode.SingleShotTime) && options.shouldSyncIterations().orElse(Defaults.SYNC_ITERATIONS); IterationParams measurement = mode.doMeasurement() ? new IterationParams( IterationType.MEASUREMENT, options.getMeasurementIterations().orElse( benchmark.getMeasurementIterations().orElse( (benchmark.getMode() == Mode.SingleShotTime) ? Defaults.MEASUREMENT_ITERATIONS_SINGLESHOT : Defaults.MEASUREMENT_ITERATIONS )), options.getMeasurementTime().orElse( benchmark.getMeasurementTime().orElse( (benchmark.getMode() == Mode.SingleShotTime) ? TimeValue.NONE : Defaults.MEASUREMENT_TIME )), options.getMeasurementBatchSize().orElse( benchmark.getMeasurementBatchSize().orElse( Defaults.MEASUREMENT_BATCHSIZE ) ) ) : new IterationParams(IterationType.MEASUREMENT, 0, TimeValue.NONE, 1); IterationParams warmup = mode.doWarmup() ? new IterationParams( IterationType.WARMUP, options.getWarmupIterations().orElse( benchmark.getWarmupIterations().orElse( (benchmark.getMode() == Mode.SingleShotTime) ? Defaults.WARMUP_ITERATIONS_SINGLESHOT : Defaults.WARMUP_ITERATIONS )), options.getWarmupTime().orElse( benchmark.getWarmupTime().orElse( (benchmark.getMode() == Mode.SingleShotTime) ? TimeValue.NONE : Defaults.WARMUP_TIME )), options.getWarmupBatchSize().orElse( benchmark.getWarmupBatchSize().orElse( Defaults.WARMUP_BATCHSIZE ) ) ) : new IterationParams(IterationType.WARMUP, 0, TimeValue.NONE, 1); int forks = options.getForkCount().orElse( benchmark.getForks().orElse( Defaults.MEASUREMENT_FORKS)); int warmupForks = options.getWarmupForkCount().orElse( benchmark.getWarmupForks().orElse( Defaults.WARMUP_FORKS)); TimeUnit timeUnit = options.getTimeUnit().orElse( benchmark.getTimeUnit().orElse( Defaults.OUTPUT_TIMEUNIT)); int opsPerInvocation = options.getOperationsPerInvocation().orElse( benchmark.getOperationsPerInvocation().orElse( Defaults.OPS_PER_INVOCATION)); String jvm = options.getJvm().orElse( benchmark.getJvm().orElse(Utils.getCurrentJvm())); Properties targetProperties; if (jvm.equals(Utils.getCurrentJvm())) { targetProperties = Utils.getRecordedSystemProperties(); } else { targetProperties = Utils.readPropertiesFromCommand(getPrintPropertiesCommand(jvm)); } Collection jvmArgs = new ArrayList<>(); jvmArgs.addAll(options.getJvmArgsPrepend().orElse( benchmark.getJvmArgsPrepend().orElse(Collections.emptyList()))); // We want to be extra lazy when accessing ManagementFactory, because security manager // may prevent us doing so. jvmArgs.addAll(options.getJvmArgs() .orElseGet(() -> benchmark.getJvmArgs() .orElseGet(() -> ManagementFactory.getRuntimeMXBean().getInputArguments()) )); jvmArgs.addAll(options.getJvmArgsAppend().orElse( benchmark.getJvmArgsAppend().orElse(Collections.emptyList()))); TimeValue timeout = options.getTimeout().orElse( benchmark.getTimeout().orElse(Defaults.TIMEOUT)); String jdkVersion = targetProperties.getProperty("java.version"); String vmVersion = targetProperties.getProperty("java.vm.version"); String vmName = targetProperties.getProperty("java.vm.name"); return new BenchmarkParams(benchmark.getUsername(), benchmark.generatedTarget(), synchIterations, threads, threadGroups, benchmark.getThreadGroupLabels().orElse(Collections.emptyList()), forks, warmupForks, warmup, measurement, benchmark.getMode(), benchmark.getWorkloadParams(), timeUnit, opsPerInvocation, jvm, jvmArgs, jdkVersion, vmName, vmVersion, Version.getPlainVersion(), timeout); } private List explodeAllParams(BenchmarkListEntry br) throws RunnerException { Map benchParams = br.getParams().orElse(Collections.emptyMap()); List ps = new ArrayList<>(); for (Map.Entry e : benchParams.entrySet()) { String k = e.getKey(); String[] vals = e.getValue(); Collection values = options.getParameter(k).orElse(Arrays.asList(vals)); if (values.isEmpty()) { throw new RunnerException("Benchmark \"" + br.getUsername() + "\" defines the parameter \"" + k + "\", but no default values.\n" + "Define the default values within the annotation, or provide the parameter values at runtime."); } if (ps.isEmpty()) { int idx = 0; for (String v : values) { WorkloadParams al = new WorkloadParams(); al.put(k, v, idx); ps.add(al); idx++; } } else { List newPs = new ArrayList<>(); for (WorkloadParams p : ps) { int idx = 0; for (String v : values) { WorkloadParams al = p.copy(); al.put(k, v, idx); newPs.add(al); idx++; } } ps = newPs; } } return ps; } private Collection runBenchmarks(SortedSet benchmarks) throws RunnerException { out.startRun(); Multimap results = new TreeMultimap<>(); List plan = getActionPlans(benchmarks); etaBeforeBenchmarks(plan); try { for (ActionPlan r : plan) { Multimap res; switch (r.getType()) { case EMBEDDED: res = runBenchmarksEmbedded(r); break; case FORKED: res = runSeparate(r); break; default: throw new IllegalStateException("Unknown action plan type: " + r.getType()); } for (BenchmarkParams br : res.keys()) { results.putAll(br, res.get(br)); } } etaAfterBenchmarks(); SortedSet runResults = mergeRunResults(results); out.endRun(runResults); return runResults; } catch (BenchmarkException be) { throw new RunnerException("Benchmark caught the exception", be); } } private SortedSet mergeRunResults(Multimap results) { SortedSet result = new TreeSet<>(RunResult.DEFAULT_SORT_COMPARATOR); for (BenchmarkParams key : results.keys()) { result.add(new RunResult(key, results.get(key))); } return result; } private Multimap runSeparate(ActionPlan actionPlan) { Multimap results = new HashMultimap<>(); if (actionPlan.getMeasurementActions().size() != 1) { throw new IllegalStateException("Expect only single benchmark in the action plan, but was " + actionPlan.getMeasurementActions().size()); } BinaryLinkServer server = null; try { server = new BinaryLinkServer(options, out); server.setPlan(actionPlan); BenchmarkParams params = actionPlan.getMeasurementActions().get(0).getParams(); List profilers = ProfilerFactory.getSupportedExternal(options.getProfilers()); boolean printOut = true; boolean printErr = true; for (ExternalProfiler prof : profilers) { printOut &= prof.allowPrintOut(); printErr &= prof.allowPrintErr(); } List profilersRev = new ArrayList<>(profilers); Collections.reverse(profilersRev); boolean forcePrint = options.verbosity().orElse(Defaults.VERBOSITY).equalsOrHigherThan(VerboseMode.EXTRA); printOut = forcePrint || printOut; printErr = forcePrint || printErr; out.startBenchmark(params); out.println(""); int forkCount = params.getForks(); int warmupForkCount = params.getWarmupForks(); int totalForks = warmupForkCount + forkCount; for (int i = 0; i < totalForks; i++) { boolean warmupFork = (i < warmupForkCount); List forkedString = getForkedMainCommand(params, profilers, server.getHost(), server.getPort()); etaBeforeBenchmark(); if (warmupFork) { out.verbosePrintln("Warmup forking using command: " + forkedString); out.println("# Warmup Fork: " + (i + 1) + " of " + warmupForkCount); } else { out.verbosePrintln("Forking using command: " + forkedString); out.println("# Fork: " + (i + 1 - warmupForkCount) + " of " + forkCount); } TempFile stdErr = FileUtils.weakTempFile("stderr"); TempFile stdOut = FileUtils.weakTempFile("stdout"); if (!profilers.isEmpty()) { out.print("# Preparing profilers: "); for (ExternalProfiler profiler : profilers) { out.print(profiler.getClass().getSimpleName() + " "); profiler.beforeTrial(params); } out.println(""); List consumed = new ArrayList<>(); if (!printOut) consumed.add("stdout"); if (!printErr) consumed.add("stderr"); if (!consumed.isEmpty()) { out.println("# Profilers consume " + Utils.join(consumed, " and ") + " from target VM, use -v " + VerboseMode.EXTRA + " to copy to console"); } } long startTime = System.currentTimeMillis(); List result = doFork(server, forkedString, stdOut.file(), stdErr.file(), printOut, printErr); if (!result.isEmpty()) { long pid = server.getClientPid(); BenchmarkResultMetaData md = server.getMetadata(); if (md != null) { md.adjustStart(startTime); } BenchmarkResult br = new BenchmarkResult(params, result, md); if (!profilersRev.isEmpty()) { out.print("# Processing profiler results: "); for (ExternalProfiler profiler : profilersRev) { out.print(profiler.getClass().getSimpleName() + " "); for (Result profR : profiler.afterTrial(br, pid, stdOut.file(), stdErr.file())) { br.addBenchmarkResult(profR); } } out.println(""); } if (!warmupFork) { results.put(params, br); } } etaAfterBenchmark(params); out.println(""); // we know these are not needed anymore, proactively delete stdOut.delete(); stdErr.delete(); } out.endBenchmark(new RunResult(params, results.get(params)).getAggregatedResult()); } catch (IOException e) { results.clear(); throw new BenchmarkException(e); } catch (BenchmarkException e) { results.clear(); if (options.shouldFailOnError().orElse(Defaults.FAIL_ON_ERROR)) { out.println("Benchmark had encountered error, and fail on error was requested"); throw e; } } finally { if (server != null) { server.terminate(); } FileUtils.purgeTemps(); } return results; } private List doFork(BinaryLinkServer reader, List commandString, File stdOut, File stdErr, boolean printOut, boolean printErr) { try (FileOutputStream fosErr = new FileOutputStream(stdErr); FileOutputStream fosOut = new FileOutputStream(stdOut)) { ProcessBuilder pb = new ProcessBuilder(commandString); Process p = pb.start(); // drain streams, else we might lock up InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), fosErr); InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), fosOut); if (printErr) { errDrainer.addOutputStream(new OutputFormatAdapter(out)); } if (printOut) { outDrainer.addOutputStream(new OutputFormatAdapter(out)); } errDrainer.start(); outDrainer.start(); int ecode = p.waitFor(); errDrainer.join(); outDrainer.join(); // need to wait for all pending messages to be processed // before starting the next benchmark reader.waitFinish(); if (ecode != 0) { out.println(""); out.println(""); for (String l : FileUtils.tail(stdOut, TAIL_LINES_ON_ERROR)) { out.println(l); } out.println(""); out.println(""); for (String l : FileUtils.tail(stdErr, TAIL_LINES_ON_ERROR)) { out.println(l); } out.println(""); out.println(""); } BenchmarkException exception = reader.getException(); if (exception == null) { if (ecode == 0) { return reader.getResults(); } else { throw new BenchmarkException(new IllegalStateException("Forked VM failed with exit code " + ecode)); } } else { throw exception; } } catch (IOException ex) { out.println(""); out.println(""); throw new BenchmarkException(ex); } catch (InterruptedException ex) { out.println(""); out.println(""); throw new BenchmarkException(ex); } } /** * @param host host VM host * @param port host VM port * @return */ List getForkedMainCommand(BenchmarkParams benchmark, List profilers, String host, int port) { // Poll profilers for options List javaInvokeOptions = new ArrayList<>(); List javaOptions = new ArrayList<>(); for (ExternalProfiler prof : profilers) { javaInvokeOptions.addAll(prof.addJVMInvokeOptions(benchmark)); javaOptions.addAll(prof.addJVMOptions(benchmark)); } List command = new ArrayList<>(); // prefix java invoke options, if any profiler wants it command.addAll(javaInvokeOptions); // use supplied jvm, if given command.add(benchmark.getJvm()); // use supplied jvm args, if given command.addAll(benchmark.getJvmArgs()); // add profiler JVM commands, if any profiler wants it command.addAll(javaOptions); // add any compiler oracle hints CompilerHints.addCompilerHints(command); // assemble final process command addClasspath(command); command.add(ForkedMain.class.getName()); // Forked VM assumes the exact order of arguments: // 1) host name to back-connect // 2) host port to back-connect command.add(host); command.add(String.valueOf(port)); return command; } private List getPrintPropertiesCommand(String jvm) { List command = new ArrayList<>(); // use supplied jvm, if given command.add(jvm); // assemble final process command addClasspath(command); command.add(PrintPropertiesMain.class.getName()); return command; } private void addClasspath(List command) { command.add("-cp"); String cpProp = System.getProperty("java.class.path"); File tmpFile = null; String jvmargs = "" + options.getJvmArgs().orElse(Collections.emptyList()) + options.getJvmArgsPrepend().orElse(Collections.emptyList()) + options.getJvmArgsAppend().orElse(Collections.emptyList()); // The second (creepy) test is for the cases when external plugins are not supplying // the options properly. Looking at you, JMH Gradle plugin. In this case, we explicitly // check if the option is provided by the user. if (Boolean.getBoolean("jmh.separateClasspathJAR") || jvmargs.contains("jmh.separateClasspathJAR=true")) { // Classpath can be too long and overflow the command line length. // Looking at you, Windows. // // The trick is to generate the JAR file with appropriate Class-Path manifest entry, // and link it. The complication is that Class-Path entry paths are specified relative // to JAR file loaded, which is probably somewhere in java.io.tmpdir, outside of current // directory. Therefore, we have to relativize the paths to all the JAR entries. try { tmpFile = FileUtils.tempFile("classpath.jar"); Path tmpFileDir = tmpFile.toPath().getParent(); StringBuilder sb = new StringBuilder(); for (String cp : cpProp.split(File.pathSeparator)) { Path cpPath = new File(cp).getAbsoluteFile().toPath(); if (!cpPath.getRoot().equals(tmpFileDir.getRoot())) { throw new IOException("Cannot relativize: " + cpPath + " and " + tmpFileDir + " have different roots."); } Path relPath = tmpFileDir.relativize(cpPath); if (!Files.isReadable(tmpFileDir.resolve(relPath))) { throw new IOException("Cannot read through the relativized path: " + relPath); } String rel = relPath.toString(); sb.append(rel.replace('\\', '/').replace(" ", "%20")); if (Files.isDirectory(cpPath)) { sb.append('/'); } sb.append(" "); } String classPath = sb.toString().trim(); Manifest manifest = new Manifest(); Attributes attrs = manifest.getMainAttributes(); attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0"); attrs.putValue("Class-Path", classPath); try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(tmpFile), manifest)) { jos.putNextEntry(new ZipEntry("META-INF/")); } out.verbosePrintln("Using separate classpath JAR: " + tmpFile); out.verbosePrintln(" Class-Path: " + classPath); } catch (IOException ex) { // Something is wrong in file generation, give up and fall-through to usual thing out.verbosePrintln("Caught IOException when building separate classpath JAR: " + ex.getMessage() + ", falling back to default -cp."); tmpFile = null; } } if (tmpFile != null) { if (Utils.isWindows()) { command.add("\"" + tmpFile.getAbsolutePath() + "\""); } else { command.add(tmpFile.getAbsolutePath()); } } else { if (Utils.isWindows()) { command.add('"' + cpProp + '"'); } else { command.add(cpProp); } } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/RunnerException.java000066400000000000000000000031531446271450100266730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; public class RunnerException extends Exception { private static final long serialVersionUID = 7366763183238649668L; public RunnerException(Throwable t) { super(t); } public RunnerException() { super(); } public RunnerException(String s) { super(s); } public RunnerException(String s, Throwable cause) { super(s, cause); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/VersionMain.java000066400000000000000000000027771446271450100260100ustar00rootroot00000000000000/* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.openjdk.jmh.util.Utils; /** * Main program entry point detecting the VM version. */ class VersionMain { /** * @param argv Command line arguments */ public static void main(String[] argv) { System.err.println(Utils.getCurrentJvmVersion()); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkerThreadFactories.java000066400000000000000000000062341446271450100300070ustar00rootroot00000000000000/* * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; class WorkerThreadFactories { static class PlatformThreadFactory implements ThreadFactory { private final AtomicInteger counter; private final String prefix; private final ThreadFactory factory; public PlatformThreadFactory(String prefix) { this.counter = new AtomicInteger(); this.prefix = prefix; this.factory = Executors.defaultThreadFactory(); } @Override public Thread newThread(Runnable r) { Thread thread = factory.newThread(r); thread.setName(prefix + "-jmh-worker-" + counter.incrementAndGet()); thread.setDaemon(true); return thread; } } static ThreadFactory platformWorkerFactory(String prefix) { return new PlatformThreadFactory(prefix); } static ThreadFactory virtualWorkerFactory(String prefix) { // This API is only available in JDK 21+. Use reflection to make the code compilable with lower JDKs. try { Method m = Class.forName("java.lang.Thread").getMethod("ofVirtual"); Object threadBuilder = m.invoke(null); Class threadBuilderClazz = Class.forName("java.lang.Thread$Builder"); m = threadBuilderClazz.getMethod("name", String.class, long.class); m.invoke(threadBuilder, prefix + "-jmh-worker-", 1L); m = threadBuilderClazz.getMethod("factory"); return (ThreadFactory) m.invoke(threadBuilder); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassNotFoundException | NullPointerException e) { throw new RuntimeException("Cannot instantiate VirtualThreadFactory", e); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java000066400000000000000000000100171446271450100264660ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import java.io.Serializable; import java.util.*; public class WorkloadParams implements Comparable, Serializable { private static final long serialVersionUID = 780563934988950196L; private final SortedMap params; public WorkloadParams() { params = new TreeMap<>(); } private WorkloadParams(SortedMap params) { this(); this.params.putAll(params); } @Override public int compareTo(WorkloadParams o) { if (!params.keySet().equals(o.params.keySet())) { throw new IllegalStateException("Comparing actual params with different key sets."); } for (Map.Entry e : params.entrySet()) { int cr = e.getValue().compareTo(o.params.get(e.getKey())); if (cr != 0) { return cr; } } return 0; } public void put(String k, String v, int vOrder) { params.put(k, new Value(v, vOrder)); } public boolean containsKey(String name) { return params.containsKey(name); } public String get(String name) { Value value = params.get(name); if (value == null) { return null; } else { return value.value; } } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; WorkloadParams that = (WorkloadParams) o; return Objects.equals(params, that.params); } @Override public int hashCode() { return params != null ? params.hashCode() : 0; } @Override public String toString() { return params.toString(); } public WorkloadParams copy() { return new WorkloadParams(params); } public boolean isEmpty() { return params.isEmpty(); } public Collection keys() { return params.keySet(); } private static class Value implements Comparable, Serializable { private static final long serialVersionUID = 8846779314306880977L; private final String value; private final int order; public Value(String value, int order) { this.value = value; this.order = order; } @Override public int compareTo(Value o) { return Integer.compare(order, o.order); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Value value1 = (Value) o; return Objects.equals(value, value1.value); } @Override public int hashCode() { return value != null ? value.hashCode() : 0; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/format/000077500000000000000000000000001446271450100241665ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/format/AbstractOutputFormat.java000066400000000000000000000043571446271450100311770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.format; import org.openjdk.jmh.runner.options.VerboseMode; import java.io.IOException; import java.io.PrintStream; abstract class AbstractOutputFormat implements OutputFormat { /** Verbose-mode? */ final VerboseMode verbose; /** PrintStream to use */ final PrintStream out; public AbstractOutputFormat(PrintStream out, VerboseMode verbose) { this.out = out; this.verbose = verbose; } @Override public void print(String s) { out.print(s); } @Override public void println(String s) { out.println(s); } @Override public void flush() { out.flush(); } @Override public void verbosePrintln(String s) { if (verbose == VerboseMode.EXTRA) { out.println(s); } } @Override public void write(int b) { out.write(b); } @Override public void write(byte[] b) throws IOException { out.write(b); } @Override public void close() { // do nothing } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/format/OutputFormat.java000066400000000000000000000057601446271450100275120ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.format; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.results.RunResult; import java.io.IOException; import java.util.Collection; /** * Internal interface for OutputFormat. */ public interface OutputFormat { /** * Format for iteration start. * * @param benchParams benchmark parameters * @param params iteration params in use * @param iteration iteration-number */ void iteration(BenchmarkParams benchParams, IterationParams params, int iteration); /** * Format for end-of-iteration. * * @param benchParams name of benchmark * @param params iteration params in use * @param iteration iteration-number * @param data result of iteration */ void iterationResult(BenchmarkParams benchParams, IterationParams params, int iteration, IterationResult data); /** * Format for start-of-benchmark output. * @param benchParams benchmark params */ void startBenchmark(BenchmarkParams benchParams); /** * Format for end-of-benchmark. * * @param result statistics of the run */ void endBenchmark(BenchmarkResult result); /** * Format for start-of-benchmark output. */ void startRun(); /** * Format for end-of-benchmark. * @param result benchmark results */ void endRun(Collection result); /* ------------- RAW OUTPUT METHODS ------------------- */ void print(String s); void println(String s); void flush(); void close(); void verbosePrintln(String s); void write(int b); void write(byte[] b) throws IOException; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/format/OutputFormatFactory.java000066400000000000000000000037231446271450100310370ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.format; import org.openjdk.jmh.runner.options.VerboseMode; import java.io.PrintStream; public class OutputFormatFactory { /** * Factory method for OutputFormat instances * * @param out output stream to use * @param mode how much verbosity to use * @return a new OutputFormat instance of given type */ public static OutputFormat createFormatInstance(PrintStream out, VerboseMode mode) { switch (mode) { case SILENT: return new SilentFormat(out, mode); case NORMAL: case EXTRA: return new TextReportFormat(out, mode); default: throw new IllegalArgumentException("Mode " + mode + " not found!"); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/format/SilentFormat.java000066400000000000000000000047401446271450100274450ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.format; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.options.VerboseMode; import java.io.PrintStream; import java.util.Collection; /** * Silent format, does nothing. */ class SilentFormat extends AbstractOutputFormat { public SilentFormat(PrintStream out, VerboseMode verbose) { super(out, verbose); } @Override public void startRun() { } @Override public void endRun(Collection results) { } @Override public void startBenchmark(BenchmarkParams benchmarkParams) { } @Override public void endBenchmark(BenchmarkResult result) { } @Override public void iteration(BenchmarkParams benchmarkParams, IterationParams params, int iteration) { } @Override public void iterationResult(BenchmarkParams benchmarkParams, IterationParams params, int iteration, IterationResult data) { } @Override public void print(String s) { } @Override public void println(String s) { } @Override public void verbosePrintln(String s) { } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/format/SupportedVMs.java000066400000000000000000000035471446271450100274550ustar00rootroot00000000000000/* * Copyright (c) 2018, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.format; /** * JMH VM support tester */ class SupportedVMs { static final String[] FULL_SUPPORT = { "OpenJDK", "HotSpot", }; static final String[] EXPERIMENTAL_SUPPORT = { "Zing", "GraalVM", }; public static Level supportLevel(String name) { for (String vmName : FULL_SUPPORT) { if (name.contains(vmName)) return Level.FULL; } for (String vmName : EXPERIMENTAL_SUPPORT) { if (name.contains(vmName)) return Level.EXPERIMENTAL; } return Level.NONE; } public enum Level { FULL, EXPERIMENTAL, NONE, } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java000066400000000000000000000233771446271450100303360ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.format; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.BenchmarkResult; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.results.format.ResultFormatFactory; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.CompilerHints; import org.openjdk.jmh.runner.IterationType; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.util.Utils; import java.io.PrintStream; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; /** * TextReportFormat implementation of OutputFormat. */ class TextReportFormat extends AbstractOutputFormat { public TextReportFormat(PrintStream out, VerboseMode verbose) { super(out, verbose); } @Override public void startBenchmark(BenchmarkParams params) { String opts = Utils.join(params.getJvmArgs(), " "); if (opts.trim().isEmpty()) { opts = ""; } println("# JMH version: " + params.getJmhVersion()); println("# VM version: JDK " + params.getJdkVersion() + ", " + params.getVmName() + ", " + params.getVmVersion()); switch (SupportedVMs.supportLevel(params.getVmName())) { case FULL: break; case EXPERIMENTAL: println("# *** WARNING: JMH support for this VM is experimental. Be extra careful with the produced data."); break; case NONE: println("# *** WARNING: This VM is not supported by JMH. The produced benchmark data can be completely wrong."); break; default: throw new IllegalStateException("Unknown support level"); } println("# VM invoker: " + params.getJvm()); println("# VM options: " + opts); CompilerHints.printHints(out); IterationParams warmup = params.getWarmup(); if (warmup.getCount() > 0) { out.println("# Warmup: " + warmup.getCount() + " iterations, " + warmup.getTime() + " each" + (warmup.getBatchSize() <= 1 ? "" : ", " + warmup.getBatchSize() + " calls per op")); } else { out.println("# Warmup: "); } IterationParams measurement = params.getMeasurement(); if (measurement.getCount() > 0) { out.println("# Measurement: " + measurement.getCount() + " iterations, " + measurement.getTime() + " each" + (measurement.getBatchSize() <= 1 ? "" : ", " + measurement.getBatchSize() + " calls per op")); } else { out.println("# Measurement: "); } TimeValue timeout = params.getTimeout(); boolean timeoutWarning = (timeout.convertTo(TimeUnit.NANOSECONDS) <= measurement.getTime().convertTo(TimeUnit.NANOSECONDS)) || (timeout.convertTo(TimeUnit.NANOSECONDS) <= warmup.getTime().convertTo(TimeUnit.NANOSECONDS)); out.println("# Timeout: " + timeout + " per iteration" + (timeoutWarning ? ", ***WARNING: The timeout might be too low!***" : "")); out.print("# Threads: " + params.getThreads() + " " + getThreadsString(params.getThreads())); if (!params.getThreadGroupLabels().isEmpty()) { int[] tg = params.getThreadGroups(); // TODO: Make params.getThreadGroupLabels return List List labels = new ArrayList<>(params.getThreadGroupLabels()); String[] ss = new String[tg.length]; for (int cnt = 0; cnt < tg.length; cnt++) { ss[cnt] = tg[cnt] + "x \"" + labels.get(cnt) + "\""; } int groupCount = params.getThreads() / Utils.sum(tg); out.print(" (" + groupCount + " " + getGroupsString(groupCount) + "; " + Utils.join(ss, ", ") + " in each group)"); } out.println(params.shouldSynchIterations() ? ", will synchronize iterations" : (params.getMode() == Mode.SingleShotTime) ? "" : ", ***WARNING: Synchronize iterations are disabled!***"); out.println("# Benchmark mode: " + params.getMode().longLabel()); out.println("# Benchmark: " + params.getBenchmark()); if (!params.getParamsKeys().isEmpty()) { String s = ""; boolean isFirst = true; for (String k : params.getParamsKeys()) { if (isFirst) { isFirst = false; } else { s += ", "; } s += k + " = " + params.getParam(k); } out.println("# Parameters: (" + s + ")"); } } @Override public void iteration(BenchmarkParams benchmarkParams, IterationParams params, int iteration) { switch (params.getType()) { case WARMUP: out.print(String.format("# Warmup Iteration %3d: ", iteration)); break; case MEASUREMENT: out.print(String.format("Iteration %3d: ", iteration)); break; default: throw new IllegalStateException("Unknown iteration type: " + params.getType()); } out.flush(); } protected static String getThreadsString(int t) { if (t > 1) { return "threads"; } else { return "thread"; } } protected static String getGroupsString(int g) { if (g > 1) { return "groups"; } else { return "group"; } } @Override public void iterationResult(BenchmarkParams benchmParams, IterationParams params, int iteration, IterationResult data) { StringBuilder sb = new StringBuilder(); sb.append(data.getPrimaryResult().toString()); if (params.getType() == IterationType.MEASUREMENT) { int prefixLen = String.format("Iteration %3d: ", iteration).length(); Map secondary = data.getSecondaryResults(); if (!secondary.isEmpty()) { sb.append("\n"); int maxKeyLen = 0; for (Map.Entry res : secondary.entrySet()) { maxKeyLen = Math.max(maxKeyLen, res.getKey().length()); } for (Map.Entry res : secondary.entrySet()) { sb.append(String.format("%" + prefixLen + "s", "")); sb.append(String.format(" %-" + (maxKeyLen + 1) + "s %s", res.getKey() + ":", res.getValue())); sb.append("\n"); } } } out.print(String.format("%s%n", sb.toString())); out.flush(); } @Override public void endBenchmark(BenchmarkResult result) { out.println(); if (result != null) { { Result r = result.getPrimaryResult(); String s = r.extendedInfo(); if (!s.trim().isEmpty()) { out.println("Result \"" + result.getParams().getBenchmark() + "\":"); out.println(s); } } for (Result r : result.getSecondaryResults().values()) { String s = r.extendedInfo(); if (!s.trim().isEmpty()) { out.println("Secondary result \"" + result.getParams().getBenchmark() + ":" + r.getLabel() + "\":"); out.println(s); } } out.println(); } } @Override public void startRun() { // do nothing } @Override public void endRun(Collection runResults) { out.println("REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on"); out.println("why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial"); out.println("experiments, perform baseline and negative tests that provide experimental control, make sure"); out.println("the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts."); out.println("Do not assume the numbers tell you what you want them to tell."); out.println(); CompilerHints.printWarnings(out); ResultFormatFactory.getInstance(ResultFormatType.TEXT, out).writeOut(runResults); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/000077500000000000000000000000001446271450100236335ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/ActionPlanFrame.java000066400000000000000000000031721446271450100275040ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import org.openjdk.jmh.runner.ActionPlan; import java.io.Serializable; class ActionPlanFrame implements Serializable { private static final long serialVersionUID = 4652437412096164885L; private final ActionPlan actionPlan; public ActionPlanFrame(ActionPlan actionPlan) { this.actionPlan = actionPlan; } public ActionPlan getActionPlan() { return actionPlan; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkClient.java000066400000000000000000000217411446271450100277040ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import org.openjdk.jmh.results.BenchmarkResultMetaData; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.runner.ActionPlan; import org.openjdk.jmh.runner.BenchmarkException; import org.openjdk.jmh.runner.format.OutputFormat; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.Utils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.PrintStream; import java.io.Serializable; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.net.Socket; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public final class BinaryLinkClient { private static final int RESET_EACH = Integer.getInteger("jmh.link.resetEach", 100); private static final int BUFFER_SIZE = Integer.getInteger("jmh.link.bufferSize", 64*1024); private final Object lock; private final Socket clientSocket; private final ObjectOutputStream oos; private final ObjectInputStream ois; private final ForwardingPrintStream streamErr; private final ForwardingPrintStream streamOut; private final OutputFormat outputFormat; private volatile boolean failed; private int resetToGo; private final List delayedFrames; private boolean inFrame; public BinaryLinkClient(String hostName, int hostPort) throws IOException { this.lock = new Object(); this.clientSocket = new Socket(hostName, hostPort); // Initialize the OOS first, and flush, letting the other party read the stream header. this.oos = new ObjectOutputStream(new BufferedOutputStream(clientSocket.getOutputStream(), BUFFER_SIZE)); this.oos.flush(); this.ois = new ObjectInputStream(new BufferedInputStream(clientSocket.getInputStream(), BUFFER_SIZE)); this.streamErr = new ForwardingPrintStream(OutputFrame.Type.ERR); this.streamOut = new ForwardingPrintStream(OutputFrame.Type.OUT); this.outputFormat = (OutputFormat) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[]{OutputFormat.class}, (proxy, method, args) -> { pushFrame(new OutputFormatFrame(ClassConventions.getMethodName(method), args)); return null; // expect null } ); this.delayedFrames = new ArrayList<>(); } private void pushFrame(Serializable frame) throws IOException { if (failed) { throw new IOException("Link had failed already"); } // It is important to reset the OOS to avoid garbage buildup in internal identity // tables. However, we cannot do that after each frame since the huge referenced // objects like benchmark and iteration parameters will be duplicated on the receiver // side. This is why we reset only each RESET_EACH frames. // // It is as much as important to flush the stream to let the other party know we // pushed something out. synchronized (lock) { if (inFrame) { // Something had produced this frame while we were writing another one. // Most probably, stdout/stderr message was produced when serializing data. // Delay this frame until the write is over, and let the original writer to // pick it up later. delayedFrames.add(frame); return; } try { inFrame = true; if (resetToGo-- < 0) { oos.reset(); resetToGo = RESET_EACH; } oos.writeObject(frame); oos.flush(); // Do all delayed frames now. On the off-chance their writes produce more frames, // drain them recursively. while (!delayedFrames.isEmpty()) { List frames = new ArrayList<>(delayedFrames); delayedFrames.clear(); for (Serializable f : frames) { oos.writeObject(f); } oos.flush(); } } catch (IOException e) { failed = true; throw e; } finally { inFrame = false; } } } private Object readFrame() throws IOException, ClassNotFoundException { try { return ois.readObject(); } catch (ClassNotFoundException | IOException ex) { failed = true; throw ex; } } public void close() throws IOException { // BinaryLinkClient (BLC) should not acquire the BLC lock while dealing with // ForwardingPrintStream (FPS): if there is a pending operation in FPS, // and it writes something out, it will acquire the BLC lock after acquiring // FPS lock => deadlock. Let FPS figure this one out on its own. FileUtils.safelyClose(streamErr); FileUtils.safelyClose(streamOut); synchronized (lock) { oos.writeObject(new FinishingFrame()); FileUtils.safelyClose(ois); FileUtils.safelyClose(oos); clientSocket.close(); } } public Options handshake() throws IOException, ClassNotFoundException { synchronized (lock) { pushFrame(new HandshakeInitFrame(Utils.getPid())); Object reply = readFrame(); if (reply instanceof HandshakeResponseFrame) { return (((HandshakeResponseFrame) reply).getOpts()); } else { throw new IllegalStateException("Got the erroneous reply: " + reply); } } } public ActionPlan requestPlan() throws IOException, ClassNotFoundException { synchronized (lock) { pushFrame(new InfraFrame(InfraFrame.Type.ACTION_PLAN_REQUEST)); Object reply = readFrame(); if (reply instanceof ActionPlanFrame) { return ((ActionPlanFrame) reply).getActionPlan(); } else { throw new IllegalStateException("Got the erroneous reply: " + reply); } } } public void pushResults(IterationResult res) throws IOException { pushFrame(new ResultsFrame(res)); } public void pushException(BenchmarkException error) throws IOException { pushFrame(new ExceptionFrame(error)); } public void pushResultMetadata(BenchmarkResultMetaData res) throws IOException { pushFrame(new ResultMetadataFrame(res)); } public PrintStream getOutStream() { return streamOut; } public PrintStream getErrStream() { return streamErr; } public OutputFormat getOutputFormat() { return outputFormat; } class ForwardingPrintStream extends PrintStream { public ForwardingPrintStream(final OutputFrame.Type type) { super(new OutputStream() { @Override public void write(int b) throws IOException { pushFrame(new OutputFrame(type, new byte[]{(byte) (b & 0xFF)})); } @Override public void write(byte[] b) throws IOException { pushFrame(new OutputFrame(type, Arrays.copyOf(b, b.length))); } @Override public void write(byte[] b, int off, int len) throws IOException { pushFrame(new OutputFrame(type, Arrays.copyOfRange(b, off, len + off))); } }); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkServer.java000066400000000000000000000325021446271450100277310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import org.openjdk.jmh.results.BenchmarkResultMetaData; import org.openjdk.jmh.results.IterationResult; import org.openjdk.jmh.runner.ActionPlan; import org.openjdk.jmh.runner.BenchmarkException; import org.openjdk.jmh.runner.Defaults; import org.openjdk.jmh.runner.format.OutputFormat; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.util.Utils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; /** * Accepts the binary data from the forked VM and pushes it to parent VM * as appropriate. This server assumes there is only the one and only * client at any given point of time. */ public final class BinaryLinkServer { private static final int BUFFER_SIZE = Integer.getInteger("jmh.link.bufferSize", 64*1024); private final Options opts; private final OutputFormat out; private final Map methods; private final Set forbidden; private final Acceptor acceptor; private final AtomicReference handler; private final AtomicReference> results; private final AtomicReference metadata; private final AtomicReference exception; private final AtomicReference plan; private volatile long clientPid; public BinaryLinkServer(Options opts, OutputFormat out) throws IOException { this.opts = opts; this.out = out; this.methods = new HashMap<>(); this.forbidden = new HashSet<>(); // enumerate methods for (Method m : OutputFormat.class.getMethods()) { // start/end run callbacks are banned, since their effects are enforced by parent instead if (m.getName().equals("startRun")) { forbidden.add(ClassConventions.getMethodName(m)); } if (m.getName().equals("endRun")) { forbidden.add(ClassConventions.getMethodName(m)); } Method prev = methods.put(ClassConventions.getMethodName(m), m); if (prev != null) { out.println("WARNING: Duplicate methods: " + m + " vs. " + prev); throw new IllegalStateException("WARNING: Duplicate methods: " + m + " vs. " + prev); } } acceptor = new Acceptor(); acceptor.start(); handler = new AtomicReference<>(); metadata = new AtomicReference<>(); results = new AtomicReference<>(new ArrayList<>()); exception = new AtomicReference<>(); plan = new AtomicReference<>(); } public void terminate() { acceptor.close(); Handler h = handler.getAndSet(null); if (h != null) { h.close(); } try { acceptor.join(); if (h != null) { h.join(); } } catch (InterruptedException e) { // ignore } } public void waitFinish() { Handler h = handler.getAndSet(null); if (h != null) { try { h.join(); } catch (InterruptedException e) { // ignore } } } public BenchmarkException getException() { return exception.getAndSet(null); } public List getResults() { List res = results.getAndSet(new ArrayList<>()); if (res != null) { return res; } else { throw new IllegalStateException("Acquiring the null result"); } } public BenchmarkResultMetaData getMetadata() { return metadata.getAndSet(null); } public void setPlan(ActionPlan actionPlan) { this.plan.set(actionPlan); } private InetAddress getListenAddress() { // Try to use user-provided override first. String addr = System.getProperty("jmh.link.address"); if (addr != null) { try { return InetAddress.getByName(addr); } catch (UnknownHostException e) { // override failed, notify user throw new IllegalStateException("Can not initialize binary link.", e); } } // Auto-detection should try to use JDK 7+ method first, it is more reliable. try { Method m = InetAddress.class.getMethod("getLoopbackAddress"); return (InetAddress) m.invoke(null); } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { // shun } // Otherwise open up the special loopback. // (It can only fail for the obscure reason) try { return InetAddress.getByAddress(new byte[] {127, 0, 0, 1}); } catch (UnknownHostException e) { // shun } // Last resort. Open the local host: this resolves // the machine name, and not reliable on mis-configured // hosts, but there is nothing else we can try. try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { throw new IllegalStateException("Can not find the address to bind to.", e); } } private int getListenPort() { return Integer.getInteger("jmh.link.port", 0); } public long getClientPid() { return clientPid; } private final class Acceptor extends Thread { private final ServerSocket server; private final InetAddress listenAddress; public Acceptor() throws IOException { listenAddress = getListenAddress(); server = new ServerSocket(getListenPort(), 50, listenAddress); } @Override public void run() { try { while (!Thread.interrupted()) { Socket clientSocket = server.accept(); Handler r = new Handler(clientSocket); if (!handler.compareAndSet(null, r)) { throw new IllegalStateException("The handler is already registered"); } r.start(); } } catch (SocketException e) { // assume this is "Socket closed", return } catch (IOException e) { throw new IllegalStateException(e); } finally { close(); } } public String getHost() { return listenAddress.getHostAddress(); } public int getPort() { // Poll the actual listen port, in case it is ephemeral return server.getLocalPort(); } public void close() { try { server.close(); } catch (IOException e) { // do nothing } } } public String getHost() { return acceptor.getHost(); } public int getPort() { return acceptor.getPort(); } private final class Handler extends Thread { private final InputStream is; private final Socket socket; private ObjectInputStream ois; private final OutputStream os; private ObjectOutputStream oos; public Handler(Socket socket) throws IOException { this.socket = socket; this.is = socket.getInputStream(); this.os = socket.getOutputStream(); // eager OOS initialization, let the other party read the stream header oos = new ObjectOutputStream(new BufferedOutputStream(os, BUFFER_SIZE)); oos.flush(); } @Override public void run() { try { // late OIS initialization, otherwise we'll block reading the header ois = new ObjectInputStream(new BufferedInputStream(is, BUFFER_SIZE)); Object obj; while ((obj = ois.readObject()) != null) { if (obj instanceof OutputFormatFrame) { handleOutputFormat((OutputFormatFrame) obj); } if (obj instanceof InfraFrame) { handleInfra((InfraFrame) obj); } if (obj instanceof HandshakeInitFrame) { handleHandshake((HandshakeInitFrame) obj); } if (obj instanceof ResultsFrame) { handleResults((ResultsFrame) obj); } if (obj instanceof ExceptionFrame) { handleException((ExceptionFrame) obj); } if (obj instanceof OutputFrame) { handleOutput((OutputFrame) obj); } if (obj instanceof ResultMetadataFrame) { handleResultMetadata((ResultMetadataFrame) obj); } if (obj instanceof FinishingFrame) { // close the streams break; } } } catch (EOFException e) { // ignore } catch (Exception e) { out.println(""); if (opts.verbosity().orElse(Defaults.VERBOSITY).equalsOrHigherThan(VerboseMode.EXTRA)) { out.println(Utils.throwableToString(e)); } } finally { close(); } } private void handleResultMetadata(ResultMetadataFrame obj) { metadata.set(obj.getMD()); } private void handleOutput(OutputFrame obj) { try { switch (obj.getType()) { case OUT: System.out.write(obj.getData()); break; case ERR: System.err.write(obj.getData()); break; } } catch (IOException e) { // swallow } } private void handleException(ExceptionFrame obj) { exception.set(obj.getError()); } private void handleResults(ResultsFrame obj) { results.get().add(obj.getRes()); } private void handleHandshake(HandshakeInitFrame obj) throws IOException { clientPid = obj.getPid(); oos.writeObject(new HandshakeResponseFrame(opts)); oos.flush(); } private void handleInfra(InfraFrame req) throws IOException { switch (req.getType()) { case ACTION_PLAN_REQUEST: oos.writeObject(new ActionPlanFrame(plan.get())); oos.flush(); break; default: throw new IllegalStateException("Unknown infrastructure request: " + req); } } private boolean handleOutputFormat(OutputFormatFrame frame) throws IllegalAccessException, InvocationTargetException { Method m = methods.get(frame.method); if (m == null) { out.println("WARNING: Unknown method to forward: " + frame.method); return true; } if (forbidden.contains(frame.method)) { return true; } m.invoke(out, frame.args); return false; } public void close() { try { socket.close(); } catch (IOException e) { // ignore } } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/ClassConventions.java000066400000000000000000000036401446271450100277740ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; class ClassConventions { private static final Map METHOD_NAMES = new HashMap<>(); public static String getMethodName(Method m) { String result = METHOD_NAMES.get(m); if (result == null) { StringBuilder builder = new StringBuilder(); builder.append(m.getName()); for (Class paramType : m.getParameterTypes()) { builder.append(paramType.getName()); builder.append(","); } result = builder.toString(); METHOD_NAMES.put(m, result); } return result; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/ExceptionFrame.java000066400000000000000000000031721446271450100274120ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import org.openjdk.jmh.runner.BenchmarkException; import java.io.Serializable; class ExceptionFrame implements Serializable { private static final long serialVersionUID = 5595622047639653401L; private final BenchmarkException error; public ExceptionFrame(BenchmarkException error) { this.error = error; } public BenchmarkException getError() { return error; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/FinishingFrame.java000066400000000000000000000025711446271450100273740ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import java.io.Serializable; class FinishingFrame implements Serializable { private static final long serialVersionUID = 2309975914801631608L; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/HandshakeInitFrame.java000066400000000000000000000030311446271450100301600ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import java.io.Serializable; class HandshakeInitFrame implements Serializable { private static final long serialVersionUID = 2082214387637725282L; private final long pid; public HandshakeInitFrame(long pid) { this.pid = pid; } public long getPid() { return pid; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/HandshakeResponseFrame.java000066400000000000000000000031401446271450100310540ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import org.openjdk.jmh.runner.options.Options; import java.io.Serializable; class HandshakeResponseFrame implements Serializable { private static final long serialVersionUID = 2082214387637725282L; private final Options opts; public HandshakeResponseFrame(Options opts) { this.opts = opts; } public Options getOpts() { return opts; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/InfraFrame.java000066400000000000000000000031121446271450100265050ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import java.io.Serializable; class InfraFrame implements Serializable { private static final long serialVersionUID = 6341776120773421805L; private final Type type; public InfraFrame(Type type) { this.type = type; } public Type getType() { return type; } public enum Type { ACTION_PLAN_REQUEST, } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/OutputFormatFrame.java000066400000000000000000000032501446271450100301220ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import java.io.Serializable; /** * Encapsulates the OutputFormat call * - method name * - arguments (assumed to be serializable) */ class OutputFormatFrame implements Serializable { private static final long serialVersionUID = -7151852354574635295L; public final String method; public final Object[] args; public OutputFormatFrame(String method, Object[] args) { this.method = method; this.args = args; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/OutputFrame.java000066400000000000000000000033121446271450100267500ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import java.io.Serializable; class OutputFrame implements Serializable { private static final long serialVersionUID = 8570795333046092668L; private final Type type; private final byte[] data; public OutputFrame(Type type, byte[] data) { this.type = type; this.data = data; } public byte[] getData() { return data; } public Type getType() { return type; } public enum Type { OUT, ERR, } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/ResultMetadataFrame.java000066400000000000000000000032101446271450100303640ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import org.openjdk.jmh.results.BenchmarkResultMetaData; import java.io.Serializable; class ResultMetadataFrame implements Serializable { private static final long serialVersionUID = -5627086531281515824L; private final BenchmarkResultMetaData md; public ResultMetadataFrame(BenchmarkResultMetaData md) { this.md = md; } public BenchmarkResultMetaData getMD() { return md; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/link/ResultsFrame.java000066400000000000000000000031401446271450100271100ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.link; import org.openjdk.jmh.results.IterationResult; import java.io.Serializable; class ResultsFrame implements Serializable { private static final long serialVersionUID = -5627086531281515824L; private final IterationResult res; public ResultsFrame(IterationResult res) { this.res = res; } public IterationResult getRes() { return res; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/000077500000000000000000000000001446271450100243715ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ChainedOptionsBuilder.java000066400000000000000000000246551446271450100314660ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.profile.Profiler; import org.openjdk.jmh.results.format.ResultFormatType; import java.util.concurrent.TimeUnit; public interface ChainedOptionsBuilder { /** * Produce the final Options * @return options object. */ Options build(); /** * Override the defaults from the given option. * You may use this only once. * * @param other options to base on * @return builder */ ChainedOptionsBuilder parent(Options other); /** * Include benchmark in the run * (Can be used multiple times) * * @param regexp to match benchmarks against * @return builder * @see org.openjdk.jmh.runner.Defaults#INCLUDE_BENCHMARKS */ ChainedOptionsBuilder include(String regexp); /** * Exclude benchmarks from the run * (Can be used multiple times) * * @param regexp to match benchmark against * @return builder */ ChainedOptionsBuilder exclude(String regexp); /** * ResultFormatType to use in the run * @param type resultformat type * @return builder * @see org.openjdk.jmh.runner.Defaults#RESULT_FORMAT */ ChainedOptionsBuilder resultFormat(ResultFormatType type); /** * Output filename to write the run log to * @param filename file name * @return builder */ ChainedOptionsBuilder output(String filename); /** * Output filename to write the result to * @param filename file name * @return builder * @see org.openjdk.jmh.runner.Defaults#RESULT_FILE_PREFIX */ ChainedOptionsBuilder result(String filename); /** * Should do GC between measurementIterations? * @param value flag * @return builder * @see org.openjdk.jmh.runner.Defaults#DO_GC */ ChainedOptionsBuilder shouldDoGC(boolean value); /** * Add the profiler in the run * @param profiler profiler class * @return builder */ ChainedOptionsBuilder addProfiler(Class profiler); /** * Add the profiler in the run * @param profiler profiler class * @param initLine profiler options initialization line * @return builder */ ChainedOptionsBuilder addProfiler(Class profiler, String initLine); /** * Add the profiler in the run * @param profiler profiler class name, or profiler alias * @return builder */ ChainedOptionsBuilder addProfiler(String profiler); /** * Add the profiler in the run * @param profiler profiler class name, or profiler alias * @param initLine profiler options initialization line * @return builder */ ChainedOptionsBuilder addProfiler(String profiler, String initLine); /** * Control verbosity level. * @param mode flag * @return builder * @see org.openjdk.jmh.runner.Defaults#VERBOSITY */ ChainedOptionsBuilder verbosity(VerboseMode mode); /** * Should fail on first benchmark error? * @param value flag * @return builder * @see org.openjdk.jmh.runner.Defaults#FAIL_ON_ERROR */ ChainedOptionsBuilder shouldFailOnError(boolean value); /** * Number of threads to run the benchmark in * @param count number of threads * @return builder * @see org.openjdk.jmh.annotations.Threads * @see org.openjdk.jmh.runner.Defaults#THREADS */ ChainedOptionsBuilder threads(int count); /** * Subgroups thread distribution. * @param groups thread distribution * @return builder * @see org.openjdk.jmh.annotations.Group * @see org.openjdk.jmh.annotations.GroupThreads */ ChainedOptionsBuilder threadGroups(int... groups); /** * Should synchronize measurementIterations? * @param value flag * @return builder * @see org.openjdk.jmh.runner.Defaults#SYNC_ITERATIONS */ ChainedOptionsBuilder syncIterations(boolean value); /** * How many warmup iterations to do? * @param value flag * @return builder * @see org.openjdk.jmh.annotations.Warmup * @see org.openjdk.jmh.runner.Defaults#WARMUP_ITERATIONS * @see org.openjdk.jmh.runner.Defaults#WARMUP_ITERATIONS_SINGLESHOT */ ChainedOptionsBuilder warmupIterations(int value); /** * How large warmup batchSize should be? * @param value batch size * @return builder * @see org.openjdk.jmh.annotations.Warmup * @see org.openjdk.jmh.runner.Defaults#WARMUP_BATCHSIZE */ ChainedOptionsBuilder warmupBatchSize(int value); /** * How long each warmup iteration should take? * @param value time * @return builder * @see org.openjdk.jmh.annotations.Warmup * @see org.openjdk.jmh.runner.Defaults#WARMUP_TIME */ ChainedOptionsBuilder warmupTime(TimeValue value); /** * Warmup mode to use * @param mode to use * @return builder * @see org.openjdk.jmh.runner.Defaults#WARMUP_MODE */ ChainedOptionsBuilder warmupMode(WarmupMode mode); /** * What other benchmarks to warmup along the way * @param regexp to match benchmarks against * @return builder */ ChainedOptionsBuilder includeWarmup(String regexp); /** * How many measurement measurementIterations to do * @param count number of iterations * @return builder * @see org.openjdk.jmh.annotations.Measurement * @see org.openjdk.jmh.runner.Defaults#MEASUREMENT_ITERATIONS * @see org.openjdk.jmh.runner.Defaults#MEASUREMENT_ITERATIONS_SINGLESHOT */ ChainedOptionsBuilder measurementIterations(int count); /** * How large measurement batchSize should be? * @param value batch size * @return builder * @see org.openjdk.jmh.annotations.Measurement * @see org.openjdk.jmh.runner.Defaults#MEASUREMENT_BATCHSIZE */ ChainedOptionsBuilder measurementBatchSize(int value); /** * How long each measurement iteration should take? * @param value time * @return builder * @see org.openjdk.jmh.annotations.Measurement * @see org.openjdk.jmh.runner.Defaults#MEASUREMENT_TIME */ ChainedOptionsBuilder measurementTime(TimeValue value); /** * Benchmark mode. * (Can be used multiple times) * * @param mode benchmark mode * @return builder * @see org.openjdk.jmh.annotations.BenchmarkMode * @see org.openjdk.jmh.runner.Defaults#BENCHMARK_MODE */ ChainedOptionsBuilder mode(Mode mode); /** * Timeunit to use in results * @param tu time unit * @return builder * @see org.openjdk.jmh.annotations.OutputTimeUnit * @see org.openjdk.jmh.runner.Defaults#OUTPUT_TIMEUNIT */ ChainedOptionsBuilder timeUnit(TimeUnit tu); /** * Operations per invocation. * @param value operations per invocation. * @return builder * @see org.openjdk.jmh.annotations.OperationsPerInvocation * @see org.openjdk.jmh.runner.Defaults#OPS_PER_INVOCATION */ ChainedOptionsBuilder operationsPerInvocation(int value); /** * Number of forks to use in the run * @param value number of forks * @return builder * @see org.openjdk.jmh.annotations.Fork * @see org.openjdk.jmh.runner.Defaults#MEASUREMENT_FORKS */ ChainedOptionsBuilder forks(int value); /** * Number of ignored forks * @param value number of ignored forks * @return builder * @see org.openjdk.jmh.annotations.Fork * @see org.openjdk.jmh.runner.Defaults#WARMUP_FORKS */ ChainedOptionsBuilder warmupForks(int value); /** * Forked JVM to use. * * @param path path to /bin/java * @return builder */ ChainedOptionsBuilder jvm(String path); /** * Forked JVM arguments. * * @param value arguments to add to the run * @return builder * @see org.openjdk.jmh.annotations.Fork */ ChainedOptionsBuilder jvmArgs(String... value); /** * Append forked JVM arguments: * These options go after other options. * * @param value arguments to add to the run * @return builder * @see org.openjdk.jmh.annotations.Fork */ ChainedOptionsBuilder jvmArgsAppend(String... value); /** * Prepend forked JVM arguments: * These options go before any other options. * * @param value arguments to add to the run * @return builder * @see org.openjdk.jmh.annotations.Fork */ ChainedOptionsBuilder jvmArgsPrepend(String... value); /** * Autodetect forked JVM arguments from the parent VM. * Overrides the jvmArgs(...) value. * * @return builder */ ChainedOptionsBuilder detectJvmArgs(); /** * Set benchmark parameter values. * The parameter values would be taken in the order given by user. * * @param name parameter * @param values sequence of values to set * @return builder * @see org.openjdk.jmh.annotations.Param */ ChainedOptionsBuilder param(String name, String... values); /** * How long to wait for iteration execution? * @param value time * @return builder * @see org.openjdk.jmh.runner.Defaults#TIMEOUT */ ChainedOptionsBuilder timeout(TimeValue value); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptionException.java000066400000000000000000000030611446271450100324720ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; public class CommandLineOptionException extends Exception { private static final long serialVersionUID = 4023975483757781721L; public CommandLineOptionException(String message) { super(message); } public CommandLineOptionException(String message, Throwable cause) { super(message, cause); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java000066400000000000000000000672271446271450100310140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import joptsimple.*; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.profile.ProfilerFactory; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.Defaults; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.Optional; import org.openjdk.jmh.util.Utils; import java.io.IOException; import java.util.*; import java.util.concurrent.TimeUnit; /** * Class that handles all the command line options. */ public class CommandLineOptions implements Options { private static final long serialVersionUID = 5565183446360224399L; private final Optional iterations; private final Optional timeout; private final Optional runTime; private final Optional batchSize; private final Optional warmupIterations; private final Optional warmupTime; private final Optional warmupBatchSize; private final List benchMode = new ArrayList<>(); private final Optional threads; private final List threadGroups = new ArrayList<>(); private final Optional synchIterations; private final Optional gcEachIteration; private final Optional verbose; private final Optional failOnError; private final List profilers = new ArrayList<>(); private final Optional timeUnit; private final Optional opsPerInvocation; private final List regexps = new ArrayList<>(); private final Optional fork; private final Optional warmupFork; private final Optional output; private final Optional result; private final Optional resultFormat; private final Optional jvm; private final Optional> jvmArgs; private final Optional> jvmArgsAppend; private final Optional> jvmArgsPrepend; private final List excludes = new ArrayList<>(); private final Optional warmupMode; private final List warmupMicros = new ArrayList<>(); private final Multimap params = new HashMultimap<>(); private final boolean list; private final boolean listWithParams; private final boolean listResultFormats; private final boolean help; private final boolean listProfilers; private final transient OptionParser parser; /** * Parses the given command line. * @param argv argument list * @throws CommandLineOptionException if some options are misspelled */ public CommandLineOptions(String... argv) throws CommandLineOptionException { parser = new OptionParser(); parser.formatHelpWith(new OptionFormatter()); OptionSpec optMeasureCount = parser.accepts("i", "Number of measurement iterations to do. " + "Measurement iterations are counted towards the benchmark score. " + "(default: " + Defaults.MEASUREMENT_ITERATIONS_SINGLESHOT + " for " + Mode.SingleShotTime + ", and " + Defaults.MEASUREMENT_ITERATIONS + " for all other modes)") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int"); OptionSpec optMeasureBatchSize = parser.accepts("bs", "Batch size: number of benchmark method " + "calls per operation. Some benchmark modes may ignore this setting, please check this separately. " + "(default: " + Defaults.MEASUREMENT_BATCHSIZE + ")") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int"); OptionSpec optMeasureTime = parser.accepts("r", "Minimum time to spend at each measurement " + "iteration. Benchmarks may generally run longer than iteration duration. " + "(default: " + Defaults.MEASUREMENT_TIME + ")") .withRequiredArg().ofType(TimeValue.class).describedAs("time"); OptionSpec optWarmupCount = parser.accepts("wi", "Number of warmup iterations to do. Warmup " + "iterations are not counted towards the benchmark score. " + "(default: " + Defaults.WARMUP_ITERATIONS_SINGLESHOT + " for " + Mode.SingleShotTime + ", and " + Defaults.WARMUP_ITERATIONS + " for all other modes)") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.NON_NEGATIVE).describedAs("int"); OptionSpec optWarmupBatchSize = parser.accepts("wbs", "Warmup batch size: number of benchmark " + "method calls per operation. Some benchmark modes may ignore this setting. " + "(default: " + Defaults.WARMUP_BATCHSIZE + ")") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int"); OptionSpec optWarmupTime = parser.accepts("w", "Minimum time to spend at each warmup iteration. " + "Benchmarks may generally run longer than iteration duration. " + "(default: " + Defaults.WARMUP_TIME + ")") .withRequiredArg().ofType(TimeValue.class).describedAs("time"); OptionSpec optTimeoutTime = parser.accepts("to", "Timeout for benchmark iteration. After reaching " + "this timeout, JMH will try to interrupt the running tasks. Non-cooperating benchmarks may ignore " + "this timeout. " + "(default: " + Defaults.TIMEOUT + ")") .withRequiredArg().ofType(TimeValue.class).describedAs("time"); OptionSpec optThreads = parser.accepts("t", "Number of worker threads to run with. 'max' means the " + "maximum number of hardware threads available on the machine, figured out by JMH itself. " + "(default: " + Defaults.THREADS + ")") .withRequiredArg().withValuesConvertedBy(ThreadsValueConverter.INSTANCE).describedAs("int"); OptionSpec optBenchmarkMode = parser.accepts("bm", "Benchmark mode. Available modes are: " + Mode.getKnown() + ". " + "(default: " + Defaults.BENCHMARK_MODE + ")") .withRequiredArg().ofType(String.class).withValuesSeparatedBy(',').describedAs("mode"); OptionSpec optSyncIters = parser.accepts("si", "Should JMH synchronize iterations? This would " + "significantly lower the noise in multithreaded tests, by making sure the measured part happens only " + "when all workers are running. " + "(default: " + Defaults.SYNC_ITERATIONS + ")") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optGC = parser.accepts("gc", "Should JMH force GC between iterations? Forcing the GC may " + "help to lower the noise in GC-heavy benchmarks, at the expense of jeopardizing GC ergonomics " + "decisions. Use with care. " + "(default: " + Defaults.DO_GC + ")") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optFOE = parser.accepts("foe", "Should JMH fail immediately if any benchmark had " + "experienced an unrecoverable error? This helps to make quick sanity tests for benchmark suites, as " + "well as make the automated runs with checking error codes. " + "(default: " + Defaults.FAIL_ON_ERROR + ")") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optVerboseMode = parser.accepts("v", "Verbosity mode. Available modes are: " + Arrays.toString(VerboseMode.values()) + ". " + "(default: " + Defaults.VERBOSITY + ")") .withRequiredArg().ofType(String.class).describedAs("mode"); OptionSpec optArgs = parser.nonOptions("Benchmarks to run (regexp+). " + "(default: " + Defaults.INCLUDE_BENCHMARKS + ")") .describedAs("regexp+"); OptionSpec optForks = parser.accepts("f", "How many times to fork a single benchmark. Use 0 to " + "disable forking altogether. Warning: disabling forking may have detrimental impact on benchmark and " + "infrastructure reliability, you might want to use different warmup mode instead. " + "(default: " + Defaults.MEASUREMENT_FORKS + ")") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.NON_NEGATIVE).describedAs("int"); OptionSpec optWarmupForks = parser.accepts("wf", "How many warmup forks to make for a single benchmark. " + "All iterations within the warmup fork are not counted towards the benchmark score. Use 0 to disable " + "warmup forks. " + "(default: " + Defaults.WARMUP_FORKS + ")") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.NON_NEGATIVE).describedAs("int"); OptionSpec optOutput = parser.accepts("o", "Redirect human-readable output to a given file.") .withRequiredArg().ofType(String.class).describedAs("filename"); OptionSpec optOutputResults = parser.accepts("rff", "Write machine-readable results to a given file. " + "The file format is controlled by -rf option. Please see the list of result formats for available " + "formats. " + "(default: " + Defaults.RESULT_FILE_PREFIX + ".)") .withRequiredArg().ofType(String.class).describedAs("filename"); OptionSpec optProfilers = parser.accepts("prof", "Use profilers to collect additional benchmark data. " + "Some profilers are not available on all JVMs and/or all OSes. Please see the list of available " + "profilers with -lprof.") .withRequiredArg().ofType(String.class).describedAs("profiler"); OptionSpec optThreadGroups = parser.accepts("tg", "Override thread group distribution for asymmetric " + "benchmarks. This option expects a comma-separated list of thread counts within the group. See " + "@Group/@GroupThreads Javadoc for more information.") .withRequiredArg().withValuesSeparatedBy(',').ofType(Integer.class) .withValuesConvertedBy(IntegerValueConverter.NON_NEGATIVE).describedAs("int+"); OptionSpec optJvm = parser.accepts("jvm", "Use given JVM for runs. This option only affects forked runs.") .withRequiredArg().ofType(String.class).describedAs("string"); OptionSpec optJvmArgs = parser.accepts("jvmArgs", "Use given JVM arguments. Most options are inherited " + "from the host VM options, but in some cases you want to pass the options only to a forked VM. Either " + "single space-separated option line, or multiple options are accepted. This option only affects forked " + "runs.") .withRequiredArg().ofType(String.class).describedAs("string"); OptionSpec optJvmArgsAppend = parser.accepts("jvmArgsAppend", "Same as jvmArgs, but append these " + "options after the already given JVM args.") .withRequiredArg().ofType(String.class).describedAs("string"); OptionSpec optJvmArgsPrepend = parser.accepts("jvmArgsPrepend", "Same as jvmArgs, but prepend these " + "options before the already given JVM arg.") .withRequiredArg().ofType(String.class).describedAs("string"); OptionSpec optTU = parser.accepts("tu", "Override time unit in benchmark results. Available time units " + "are: [m, s, ms, us, ns]. " + "(default: " + Defaults.OUTPUT_TIMEUNIT + ")") .withRequiredArg().ofType(String.class).describedAs("TU"); OptionSpec optOPI = parser.accepts("opi", "Override operations per invocation, see " + "@OperationsPerInvocation Javadoc for details. " + "(default: " + Defaults.OPS_PER_INVOCATION + ")") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int"); OptionSpec optResultFormat = parser.accepts("rf", "Format type for machine-readable results. These " + "results are written to a separate file (see -rff). See the list of available result formats with -lrf. " + "(default: " + Defaults.RESULT_FORMAT +")") .withRequiredArg().ofType(String.class).describedAs("type"); OptionSpec optWarmupMode = parser.accepts("wm", "Warmup mode for warming up selected benchmarks. " + "Warmup modes are: " + warmupModesDesc() + "(default: " + Defaults.WARMUP_MODE + ")") .withRequiredArg().ofType(String.class).describedAs("mode"); OptionSpec optExcludes = parser.accepts("e", "Benchmarks to exclude from the run.") .withRequiredArg().withValuesSeparatedBy(',').ofType(String.class).describedAs("regexp+"); OptionSpec optParams = parser.accepts("p", "Benchmark parameters. This option is expected to be used " + "once per parameter. Parameter name and parameter values should be separated with equals sign. " + "Parameter values should be separated with commas.") .withRequiredArg().ofType(String.class).describedAs("param={v,}*"); OptionSpec optWarmupBenchmarks = parser.accepts("wmb", "Warmup benchmarks to include in the run in " + "addition to already selected by the primary filters. Harness will not measure these benchmarks, but " + "only use them for the warmup.") .withRequiredArg().withValuesSeparatedBy(',').ofType(String.class).describedAs("regexp+"); parser.accepts("l", "List the benchmarks that match a filter, and exit."); parser.accepts("lp", "List the benchmarks that match a filter, along with parameters, and exit."); parser.accepts("lrf", "List machine-readable result formats, and exit."); parser.accepts("lprof", "List profilers, and exit."); parser.accepts("h", "Display help, and exit."); try { OptionSet set = parser.parse(argv); if (set.has(optExcludes)) { excludes.addAll(optExcludes.values(set)); } if (set.has(optWarmupBenchmarks)) { warmupMicros.addAll(optWarmupBenchmarks.values(set)); } if (set.has(optTU)) { String va = optTU.value(set); TimeUnit tu; if (va.equalsIgnoreCase("ns")) { tu = TimeUnit.NANOSECONDS; } else if (va.equalsIgnoreCase("us")) { tu = TimeUnit.MICROSECONDS; } else if (va.equalsIgnoreCase("ms")) { tu = TimeUnit.MILLISECONDS; } else if (va.equalsIgnoreCase("s")) { tu = TimeUnit.SECONDS; } else if (va.equalsIgnoreCase("m")) { tu = TimeUnit.MINUTES; } else if (va.equalsIgnoreCase("h")) { tu = TimeUnit.HOURS; } else { throw new CommandLineOptionException("Unknown time unit: " + va); } timeUnit = Optional.of(tu); } else { timeUnit = Optional.none(); } opsPerInvocation = toOptional(optOPI, set); if (set.has(optWarmupMode)) { try { warmupMode = Optional.of(WarmupMode.valueOf(optWarmupMode.value(set))); } catch (IllegalArgumentException iae) { throw new CommandLineOptionException(iae.getMessage(), iae); } } else { warmupMode = Optional.none(); } if (set.has(optResultFormat)) { try { resultFormat = Optional.of(ResultFormatType.valueOf(optResultFormat.value(set).toUpperCase())); } catch (IllegalArgumentException iae) { throw new CommandLineOptionException(iae.getMessage(), iae); } } else { resultFormat = Optional.none(); } help = set.has("h"); list = set.has("l"); listWithParams = set.has("lp"); listResultFormats = set.has("lrf"); listProfilers = set.has("lprof"); iterations = toOptional(optMeasureCount, set); batchSize = toOptional(optMeasureBatchSize, set); runTime = toOptional(optMeasureTime, set); warmupIterations = toOptional(optWarmupCount, set); warmupBatchSize = toOptional(optWarmupBatchSize, set); warmupTime = toOptional(optWarmupTime, set); timeout = toOptional(optTimeoutTime, set); threads = toOptional(optThreads, set); synchIterations = toOptional(optSyncIters, set); gcEachIteration = toOptional(optGC, set); failOnError = toOptional(optFOE, set); fork = toOptional(optForks, set); warmupFork = toOptional(optWarmupForks, set); output = toOptional(optOutput, set); result = toOptional(optOutputResults, set); if (set.has(optBenchmarkMode)) { try { List modes = new ArrayList<>(); for (String m : optBenchmarkMode.values(set)) { modes.add(Mode.deepValueOf(m)); } benchMode.addAll(modes); } catch (IllegalArgumentException iae) { throw new CommandLineOptionException(iae.getMessage(), iae); } } if (set.has(optVerboseMode)) { try { if (set.hasArgument(optVerboseMode)) { verbose = Optional.of(VerboseMode.valueOf(set.valueOf(optVerboseMode).toUpperCase())); } else { verbose = Optional.of(VerboseMode.EXTRA); } } catch (IllegalArgumentException iae) { throw new CommandLineOptionException(iae.getMessage(), iae); } } else { verbose = Optional.none(); } regexps.addAll(set.valuesOf(optArgs)); if (set.has(optProfilers)) { try { for (String m : optProfilers.values(set)) { int idx = m.indexOf(":"); String profName = (idx == -1) ? m : m.substring(0, idx); String params = (idx == -1) ? "" : m.substring(idx + 1); profilers.add(new ProfilerConfig(profName, params)); } } catch (IllegalArgumentException iae) { throw new CommandLineOptionException(iae.getMessage(), iae); } } if (set.has(optThreadGroups)) { threadGroups.addAll(set.valuesOf(optThreadGroups)); int total = 0; for (int group : threadGroups) { total += group; } if (total <= 0) { throw new CommandLineOptionException("Group thread count should be positive, but it is " + total); } } jvm = toOptional(optJvm, set); jvmArgs = treatQuoted(set, optJvmArgs); jvmArgsAppend = treatQuoted(set, optJvmArgsAppend); jvmArgsPrepend = treatQuoted(set, optJvmArgsPrepend); if (set.hasArgument(optParams)) { for (String p : optParams.values(set)) { String[] keys = p.split("=", 2); if (keys.length != 2) { throw new CommandLineOptionException("Unable to parse parameter string \"" + p + "\""); } params.putAll(keys[0], Arrays.asList(keys[1].split(","))); } } } catch (OptionException e) { String message = e.getMessage(); Throwable cause = e.getCause(); if (cause instanceof ValueConversionException) { message += ". " + cause.getMessage(); } throw new CommandLineOptionException(message, e); } } private String warmupModesDesc() { StringBuilder sb = new StringBuilder(); for (WarmupMode mode : WarmupMode.values()) { sb.append(mode); sb.append(" = "); switch (mode) { case BULK: sb.append("Warmup all benchmarks first, then do all the measurements. "); break; case INDI: sb.append("Warmup each benchmark individually, then measure it. "); break; case BULK_INDI: sb.append("Warmup all benchmarks first, then re-warmup each benchmark individually, then measure it. "); break; } } return sb.toString(); } private static Optional toOptional(OptionSpec option, OptionSet set) { if (set.has(option)) { return Optional.eitherOf(option.value(set)); } return Optional.none(); } public Optional> treatQuoted(OptionSet set, OptionSpec spec) { if (set.hasArgument(spec)) { try { List vals = spec.values(set); if (vals.size() != 1) { return Optional.>of(vals); } else { // Windows launcher somehow ends up here, fall-through to single value treatment } } catch (OptionException e) { // only a single value, fall through } return Optional.of(Utils.splitQuotedEscape(spec.value(set))); } return Optional.none(); } public void showHelp() throws IOException { parser.printHelpOn(System.out); } public void listProfilers() { ProfilerFactory.listProfilers(System.out); } public void listResultFormats() { StringBuilder sb = new StringBuilder(); for (ResultFormatType f : ResultFormatType.values()) { sb.append(f.toString().toLowerCase()); sb.append(", "); } sb.setLength(sb.length() - 2); System.out.println("Available formats: " + sb.toString()); } public boolean shouldList() { return list; } public boolean shouldListWithParams() { return listWithParams; } public boolean shouldListResultFormats() { return listResultFormats; } public boolean shouldHelp() { return help; } public boolean shouldListProfilers() { return listProfilers; } @Override public Optional getWarmupMode() { return warmupMode; } @Override public List getIncludes() { return regexps; } @Override public List getExcludes() { return excludes; } @Override public List getWarmupIncludes() { return warmupMicros; } @Override public Optional getJvm() { return jvm; } @Override public Optional> getJvmArgs() { return jvmArgs; } @Override public Optional> getJvmArgsAppend() { return jvmArgsAppend; } @Override public Optional> getJvmArgsPrepend() { return jvmArgsPrepend; } @Override public Optional> getParameter(String name) { Collection list = params.get(name); if (list == null || list.isEmpty()){ return Optional.none(); } else { return Optional.of(list); } } @Override public Optional getForkCount() { return fork; } @Override public Optional getWarmupForkCount() { return warmupFork; } @Override public Optional getOutput() { return output; } @Override public Optional getResultFormat() { return resultFormat; } @Override public Optional getResult() { return result; } @Override public Optional getMeasurementIterations() { return iterations; } @Override public Optional getMeasurementBatchSize() { return batchSize; } @Override public Optional getMeasurementTime() { return runTime; } @Override public Optional getWarmupTime() { return warmupTime; } @Override public Optional getWarmupIterations() { return warmupIterations; } @Override public Optional getWarmupBatchSize() { return warmupBatchSize; } @Override public Optional getThreads() { return threads; } @Override public Optional getThreadGroups() { if (threadGroups.isEmpty()) { return Optional.none(); } else { int[] r = new int[threadGroups.size()]; for (int c = 0; c < r.length; c++) { r[c] = threadGroups.get(c); } return Optional.of(r); } } @Override public Optional shouldDoGC() { return gcEachIteration; } @Override public Optional shouldSyncIterations() { return synchIterations; } @Override public Optional verbosity() { return verbose; } @Override public Optional getTimeUnit() { return timeUnit; } @Override public Optional getOperationsPerInvocation() { return opsPerInvocation; } @Override public Optional shouldFailOnError() { return failOnError; } @Override public List getProfilers() { return profilers; } @Override public Collection getBenchModes() { return new HashSet<>(benchMode); } @Override public Optional getTimeout() { return timeout; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/IntegerValueConverter.java000066400000000000000000000055351446271450100315260ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import joptsimple.ValueConversionException; import joptsimple.ValueConverter; import joptsimple.internal.Reflection; /** * Converts option value from {@link String} to {@link Integer} and makes sure the value exceeds given minimal threshold. */ public class IntegerValueConverter implements ValueConverter { private final static ValueConverter TO_INT_CONVERTER = Reflection.findConverter(int.class); public final static IntegerValueConverter POSITIVE = new IntegerValueConverter(1); public final static IntegerValueConverter NON_NEGATIVE = new IntegerValueConverter(0); private final int minValue; public IntegerValueConverter(int minValue) { this.minValue = minValue; } @Override public Integer convert(String value) { Integer newValue = TO_INT_CONVERTER.convert(value); if (newValue == null) { // should not get here throw new ValueConversionException("value should not be null"); } if (newValue < minValue) { String message = "The given value " + value + " should be "; if (minValue == 0) { message += "non-negative"; } else if (minValue == 1) { message += "positive"; } else { message += "greater or equal than " + minValue; } throw new ValueConversionException(message); } return newValue; } @Override public Class valueType() { return TO_INT_CONVERTER.valueType(); } @Override public String valuePattern() { return "int"; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionFormatter.java000066400000000000000000000074431446271450100304000ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import joptsimple.HelpFormatter; import joptsimple.OptionDescriptor; import org.openjdk.jmh.util.Utils; import java.util.List; import java.util.Map; public class OptionFormatter implements HelpFormatter { private static final String LINE_SEPARATOR = System.getProperty("line.separator"); public String format(Map options) { StringBuilder sb = new StringBuilder(); sb.append("Usage: java -jar ... [regexp*] [options]"); sb.append("\n"); sb.append(" [opt] means optional argument.\n"); sb.append(" means required argument.\n"); sb.append(" \"+\" means comma-separated list of values.\n"); sb.append(" \"time\" arguments accept time suffixes, like \"100ms\".\n"); sb.append("\n"); sb.append("Command line options usually take precedence over annotations."); sb.append("\n"); sb.append("\n"); for (OptionDescriptor each : options.values()) { sb.append(lineFor(each)); } return sb.toString(); } private String lineFor(OptionDescriptor d) { StringBuilder line = new StringBuilder(); StringBuilder o = new StringBuilder(); o.append(" "); for (String str : d.options()) { if (!d.representsNonOptions()) { o.append("-"); } o.append(str); if (d.acceptsArguments()) { o.append(" "); if (d.requiresArgument()) { o.append("<"); } else { o.append("["); } o.append(d.argumentDescription()); if (d.requiresArgument()) { o.append(">"); } else { o.append("]"); } } } final int optWidth = 30; line.append(String.format("%-" + optWidth + "s", o.toString())); boolean first = true; String desc = d.description(); List defaults = d.defaultValues(); if (defaults != null && !defaults.isEmpty()) { desc += " (default: " + defaults.toString() + ")"; } for (String l : Utils.rewrap(desc)) { if (first) { first = false; } else { line.append(LINE_SEPARATOR); line.append(String.format("%-" + optWidth + "s", "")); } line.append(l); } line.append(LINE_SEPARATOR); line.append(LINE_SEPARATOR); return line.toString(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/Options.java000066400000000000000000000157561446271450100267050ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.util.Optional; import java.io.Serializable; import java.util.Collection; import java.util.List; import java.util.concurrent.TimeUnit; public interface Options extends Serializable { /** * Which benchmarks to execute? * @return list of regexps matching the requested benchmarks */ List getIncludes(); /** * Which benchmarks to omit? * @return list of regexps matching the ignored benchmarks */ List getExcludes(); /** * Which file to use for dumping the output * @return file name */ Optional getOutput(); /** * Result format to use * @return format type */ Optional getResultFormat(); /** * Which file to use for dumping the result * @return file name */ Optional getResult(); /** * Should force GC between iterations? * @return should GC? */ Optional shouldDoGC(); /** * Profilers to use for the run. * Profilers will start in the order specified by collection, and will stop in the reverse order. * @return profilers to use; empty collection if no profilers are required */ List getProfilers(); /** * How verbose should we be? * @return verbosity mode */ Optional verbosity(); /** * Should harness terminate on first error encountered? * @return should terminate? */ Optional shouldFailOnError(); /** * Number of threads to run * @return number of threads; 0 to use maximum number of threads * @see org.openjdk.jmh.annotations.Threads */ Optional getThreads(); /** * Thread subgroups distribution. * @return array of thread ratios * @see org.openjdk.jmh.annotations.Group * @see org.openjdk.jmh.annotations.GroupThreads */ Optional getThreadGroups(); /** * Should synchronize iterations? * @return should we? */ Optional shouldSyncIterations(); /** * Number of warmup iterations * @return number of warmup iterations * @see org.openjdk.jmh.annotations.Warmup */ Optional getWarmupIterations(); /** * The duration for warmup iterations * @return duration * @see org.openjdk.jmh.annotations.Warmup */ Optional getWarmupTime(); /** * Number of batch size for warmup * @return number of batch size for warmup * @see org.openjdk.jmh.annotations.Warmup */ Optional getWarmupBatchSize(); /** * Warmup mode. * @return warmup mode * @see org.openjdk.jmh.runner.options.WarmupMode */ Optional getWarmupMode(); /** * Which benchmarks to warmup before doing the run. * @return list of regexps matching the relevant benchmarks; empty if no benchmarks are defined */ List getWarmupIncludes(); /** * Number of measurement iterations * @return number of measurement iterations * @see org.openjdk.jmh.annotations.Measurement */ Optional getMeasurementIterations(); /** * The duration for measurement iterations * @return duration * @see org.openjdk.jmh.annotations.Measurement */ Optional getMeasurementTime(); /** * Number of batch size for measurement * @return number of batch size for measurement * @see org.openjdk.jmh.annotations.Measurement */ Optional getMeasurementBatchSize(); /** * Benchmarks modes to execute. * @return modes to execute the benchmarks in; empty to use the default modes * @see org.openjdk.jmh.annotations.BenchmarkMode */ Collection getBenchModes(); /** * Timeunit to use in units. * @return timeunit * @see org.openjdk.jmh.annotations.OutputTimeUnit */ Optional getTimeUnit(); /** * Operations per invocation. * @return operations per invocation. * @see org.openjdk.jmh.annotations.OperationsPerInvocation */ Optional getOperationsPerInvocation(); /** * Fork count * @return fork count; 0, to prohibit forking * @see org.openjdk.jmh.annotations.Fork */ Optional getForkCount(); /** * Number of initial forks to ignore the results for * @return initial fork count; 0, to disable * @see org.openjdk.jmh.annotations.Fork */ Optional getWarmupForkCount(); /** * JVM executable to use for forks * @return path to JVM executable */ Optional getJvm(); /** * JVM parameters to use with forks * @return JVM parameters * @see org.openjdk.jmh.annotations.Fork */ Optional> getJvmArgs(); /** * JVM parameters to use with forks (these options will be appended * after any other JVM option) * @return JVM parameters * @see org.openjdk.jmh.annotations.Fork */ Optional> getJvmArgsAppend(); /** * JVM parameters to use with forks (these options will be prepended * before any other JVM option) * @return JVM parameters * @see org.openjdk.jmh.annotations.Fork */ Optional> getJvmArgsPrepend(); /** * The overridden value of the parameter. * @param name parameter name * @return parameter * @see org.openjdk.jmh.annotations.Param */ Optional> getParameter(String name); /** * Timeout: how long to wait for an iteration to complete. * @return duration */ Optional getTimeout(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java000066400000000000000000000521231446271450100302010ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.profile.Profiler; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.Optional; import org.openjdk.jmh.util.Utils; import java.lang.management.ManagementFactory; import java.util.*; import java.util.concurrent.TimeUnit; public class OptionsBuilder implements Options, ChainedOptionsBuilder { private static final long serialVersionUID = -4088596253924343849L; @Override public Options build() { return this; } // --------------------------------------------------------------------------- private Options otherOptions; @Override public ChainedOptionsBuilder parent(Options other) { this.otherOptions = other; return this; } private static void checkGreaterOrEqual(int value, int minValue, String s) { if (value >= minValue) { return; } String message = s + " (" + value + ") should be "; if (minValue == 0) { message += "non-negative"; } else if (minValue == 1) { message += "positive"; } else { message += "greater or equal than " + minValue; } throw new IllegalArgumentException(message); } // --------------------------------------------------------------------------- private final List regexps = new ArrayList<>(); @Override public ChainedOptionsBuilder include(String regexp) { regexps.add(regexp); return this; } @Override public List getIncludes() { List result = new ArrayList<>(); result.addAll(regexps); if (otherOptions != null) { result.addAll(otherOptions.getIncludes()); } return result; } // --------------------------------------------------------------------------- private final List excludes = new ArrayList<>(); @Override public ChainedOptionsBuilder exclude(String regexp) { excludes.add(regexp); return this; } @Override public List getExcludes() { List result = new ArrayList<>(); result.addAll(excludes); if (otherOptions != null) { result.addAll(otherOptions.getExcludes()); } return result; } // --------------------------------------------------------------------------- private Optional output = Optional.none(); @Override public ChainedOptionsBuilder output(String filename) { this.output = Optional.of(filename); return this; } @Override public Optional getOutput() { if (otherOptions != null) { return output.orAnother(otherOptions.getOutput()); } else { return output; } } // --------------------------------------------------------------------------- private Optional rfType = Optional.none(); @Override public ChainedOptionsBuilder resultFormat(ResultFormatType type) { rfType = Optional.of(type); return this; } @Override public Optional getResultFormat() { if (otherOptions != null) { return rfType.orAnother(otherOptions.getResultFormat()); } else { return rfType; } } // --------------------------------------------------------------------------- private Optional result = Optional.none(); @Override public ChainedOptionsBuilder result(String filename) { this.result = Optional.of(filename); return this; } @Override public Optional getResult() { if (otherOptions != null) { return result.orAnother(otherOptions.getResult()); } else { return result; } } // --------------------------------------------------------------------------- private Optional shouldDoGC = Optional.none(); @Override public ChainedOptionsBuilder shouldDoGC(boolean value) { shouldDoGC = Optional.of(value); return this; } @Override public Optional shouldDoGC() { if (otherOptions != null) { return shouldDoGC.orAnother(otherOptions.shouldDoGC()); } else { return shouldDoGC; } } // --------------------------------------------------------------------------- private final List profilers = new ArrayList<>(); @Override public ChainedOptionsBuilder addProfiler(Class prof) { this.profilers.add(new ProfilerConfig(prof.getCanonicalName())); return this; } @Override public ChainedOptionsBuilder addProfiler(Class prof, String initLine) { this.profilers.add(new ProfilerConfig(prof.getCanonicalName(), initLine)); return this; } @Override public ChainedOptionsBuilder addProfiler(String prof) { this.profilers.add(new ProfilerConfig(prof, "")); return this; } @Override public ChainedOptionsBuilder addProfiler(String prof, String initLine) { this.profilers.add(new ProfilerConfig(prof, initLine)); return this; } @Override public List getProfilers() { List result = new ArrayList<>(); result.addAll(profilers); if (otherOptions != null) { result.addAll(otherOptions.getProfilers()); } return result; } // --------------------------------------------------------------------------- private Optional verbosity = Optional.none(); @Override public ChainedOptionsBuilder verbosity(VerboseMode mode) { verbosity = Optional.of(mode); return this; } @Override public Optional verbosity() { if (otherOptions != null) { return verbosity.orAnother(otherOptions.verbosity()); } else { return verbosity; } } // --------------------------------------------------------------------------- private Optional shouldFailOnError = Optional.none(); @Override public ChainedOptionsBuilder shouldFailOnError(boolean value) { shouldFailOnError = Optional.of(value); return this; } @Override public Optional shouldFailOnError() { if (otherOptions != null) { return shouldFailOnError.orAnother(otherOptions.shouldFailOnError()); } else { return shouldFailOnError; } } // --------------------------------------------------------------------------- private Optional threads = Optional.none(); @Override public ChainedOptionsBuilder threads(int count) { if (count != Threads.MAX) { checkGreaterOrEqual(count, 1, "Threads"); } this.threads = Optional.of(count); return this; } @Override public Optional getThreads() { if (otherOptions != null) { return threads.orAnother(otherOptions.getThreads()); } else { return threads; } } // --------------------------------------------------------------------------- private Optional threadGroups = Optional.none(); @Override public ChainedOptionsBuilder threadGroups(int... groups) { if (groups != null) { for (int i = 0; i < groups.length; i++) { checkGreaterOrEqual(groups[i], 0, "Group #" + i + " thread count"); } checkGreaterOrEqual(Utils.sum(groups), 1, "Group thread count"); } this.threadGroups = Optional.of((groups == null || groups.length != 0) ? groups : null); return this; } @Override public Optional getThreadGroups() { if (otherOptions != null) { return threadGroups.orAnother(otherOptions.getThreadGroups()); } else { return threadGroups; } } // --------------------------------------------------------------------------- private Optional syncIterations = Optional.none(); @Override public ChainedOptionsBuilder syncIterations(boolean value) { this.syncIterations = Optional.of(value); return this; } @Override public Optional shouldSyncIterations() { if (otherOptions != null) { return syncIterations.orAnother(otherOptions.shouldSyncIterations()); } else { return syncIterations; } } // --------------------------------------------------------------------------- private Optional warmupIterations = Optional.none(); @Override public ChainedOptionsBuilder warmupIterations(int value) { checkGreaterOrEqual(value, 0, "Warmup iterations"); this.warmupIterations = Optional.of(value); return this; } @Override public Optional getWarmupIterations() { if (otherOptions != null) { return warmupIterations.orAnother(otherOptions.getWarmupIterations()); } else { return warmupIterations; } } // --------------------------------------------------------------------------- private Optional warmupBatchSize = Optional.none(); @Override public ChainedOptionsBuilder warmupBatchSize(int value) { checkGreaterOrEqual(value, 1, "Warmup batch size"); this.warmupBatchSize = Optional.of(value); return this; } @Override public Optional getWarmupBatchSize() { if (otherOptions != null) { return warmupBatchSize.orAnother(otherOptions.getWarmupBatchSize()); } else { return warmupBatchSize; } } // --------------------------------------------------------------------------- private Optional warmupTime = Optional.none(); @Override public ChainedOptionsBuilder warmupTime(TimeValue value) { this.warmupTime = Optional.of(value); return this; } @Override public Optional getWarmupTime() { if (otherOptions != null) { return warmupTime.orAnother(otherOptions.getWarmupTime()); } else { return warmupTime; } } // --------------------------------------------------------------------------- private Optional warmupMode = Optional.none(); @Override public ChainedOptionsBuilder warmupMode(WarmupMode mode) { this.warmupMode = Optional.of(mode); return this; } @Override public Optional getWarmupMode() { if (otherOptions != null) { return warmupMode.orAnother(otherOptions.getWarmupMode()); } else { return warmupMode; } } // --------------------------------------------------------------------------- private final List warmupMicros = new ArrayList<>(); @Override public ChainedOptionsBuilder includeWarmup(String regexp) { warmupMicros.add(regexp); return this; } @Override public List getWarmupIncludes() { List result = new ArrayList<>(); result.addAll(warmupMicros); if (otherOptions != null) { result.addAll(otherOptions.getWarmupIncludes()); } return result; } // --------------------------------------------------------------------------- private Optional iterations = Optional.none(); @Override public ChainedOptionsBuilder measurementIterations(int count) { checkGreaterOrEqual(count, 1, "Measurement iterations"); this.iterations = Optional.of(count); return this; } @Override public Optional getMeasurementIterations() { if (otherOptions != null) { return iterations.orAnother(otherOptions.getMeasurementIterations()); } else { return iterations; } } // --------------------------------------------------------------------------- private Optional measurementTime = Optional.none(); @Override public ChainedOptionsBuilder measurementTime(TimeValue value) { this.measurementTime = Optional.of(value); return this; } @Override public Optional getMeasurementTime() { if (otherOptions != null) { return measurementTime.orAnother(otherOptions.getMeasurementTime()); } else { return measurementTime; } } // --------------------------------------------------------------------------- private Optional measurementBatchSize = Optional.none(); @Override public ChainedOptionsBuilder measurementBatchSize(int value) { checkGreaterOrEqual(value, 1, "Measurement batch size"); this.measurementBatchSize = Optional.of(value); return this; } @Override public Optional getMeasurementBatchSize() { if (otherOptions != null) { return measurementBatchSize.orAnother(otherOptions.getMeasurementBatchSize()); } else { return measurementBatchSize; } } // --------------------------------------------------------------------------- private final EnumSet benchModes = EnumSet.noneOf(Mode.class); @Override public ChainedOptionsBuilder mode(Mode mode) { benchModes.add(mode); return this; } @Override public Collection getBenchModes() { if (otherOptions != null && benchModes.isEmpty()) { return otherOptions.getBenchModes(); } else { return benchModes; } } // --------------------------------------------------------------------------- private Optional timeUnit = Optional.none(); @Override public ChainedOptionsBuilder timeUnit(TimeUnit tu) { this.timeUnit = Optional.of(tu); return this; } @Override public Optional getTimeUnit() { if (otherOptions != null) { return timeUnit.orAnother(otherOptions.getTimeUnit()); } else { return timeUnit; } } // --------------------------------------------------------------------------- private Optional opsPerInvocation = Optional.none(); @Override public ChainedOptionsBuilder operationsPerInvocation(int opsPerInv) { checkGreaterOrEqual(opsPerInv, 1, "Operations per invocation"); this.opsPerInvocation = Optional.of(opsPerInv); return this; } @Override public Optional getOperationsPerInvocation() { if (otherOptions != null) { return opsPerInvocation.orAnother(otherOptions.getOperationsPerInvocation()); } else { return opsPerInvocation; } } // --------------------------------------------------------------------------- private Optional forks = Optional.none(); @Override public ChainedOptionsBuilder forks(int value) { checkGreaterOrEqual(value, 0, "Forks"); this.forks = Optional.of(value); return this; } @Override public Optional getForkCount() { if (otherOptions != null) { return forks.orAnother(otherOptions.getForkCount()); } else { return forks; } } // --------------------------------------------------------------------------- private Optional warmupForks = Optional.none(); @Override public ChainedOptionsBuilder warmupForks(int value) { checkGreaterOrEqual(value, 0, "Warmup forks"); this.warmupForks = Optional.of(value); return this; } @Override public Optional getWarmupForkCount() { if (otherOptions != null) { return warmupForks.orAnother(otherOptions.getWarmupForkCount()); } else { return warmupForks; } } // --------------------------------------------------------------------------- private Optional jvmBinary = Optional.none(); @Override public ChainedOptionsBuilder jvm(String path) { this.jvmBinary = Optional.of(path); return this; } @Override public Optional getJvm() { if (otherOptions != null) { return jvmBinary.orAnother(otherOptions.getJvm()); } else { return jvmBinary; } } // --------------------------------------------------------------------------- private Optional> jvmArgs = Optional.none(); @Override public ChainedOptionsBuilder jvmArgs(String... value) { jvmArgs = Optional.>of(Arrays.asList(value)); return this; } @Override public Optional> getJvmArgs() { if (otherOptions != null) { return jvmArgs.orAnother(otherOptions.getJvmArgs()); } else { return jvmArgs; } } // --------------------------------------------------------------------------- private Optional> jvmArgsAppend = Optional.none(); @Override public ChainedOptionsBuilder jvmArgsAppend(String... value) { jvmArgsAppend = Optional.>of(Arrays.asList(value)); return this; } @Override public Optional> getJvmArgsAppend() { if (otherOptions != null) { return jvmArgsAppend.orAnother(otherOptions.getJvmArgsAppend()); } else { return jvmArgsAppend; } } // --------------------------------------------------------------------------- private Optional> jvmArgsPrepend = Optional.none(); @Override public ChainedOptionsBuilder jvmArgsPrepend(String... value) { jvmArgsPrepend = Optional.>of(Arrays.asList(value)); return this; } @Override public Optional> getJvmArgsPrepend() { if (otherOptions != null) { return jvmArgsPrepend.orAnother(otherOptions.getJvmArgsPrepend()); } else { return jvmArgsPrepend; } } // --------------------------------------------------------------------------- @Override public ChainedOptionsBuilder detectJvmArgs() { List inputArguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); return jvmArgs(inputArguments.toArray(new String[0])); } // --------------------------------------------------------------------------- private final Multimap params = new HashMultimap<>(); @Override public Optional> getParameter(String name) { Collection list = params.get(name); if (list == null || list.isEmpty()){ if (otherOptions != null) { return otherOptions.getParameter(name); } else { return Optional.none(); } } else { return Optional.of(list); } } @Override public ChainedOptionsBuilder param(String name, String... values) { params.putAll(name, Arrays.asList(values)); return this; } // --------------------------------------------------------------------------- private Optional timeout = Optional.none(); @Override public ChainedOptionsBuilder timeout(TimeValue value) { this.timeout = Optional.of(value); return this; } @Override public Optional getTimeout() { if (otherOptions != null) { return timeout.orAnother(otherOptions.getTimeout()); } else { return timeout; } } // --------------------------------------------------------------------------- } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ProfilerConfig.java000066400000000000000000000045361446271450100301540ustar00rootroot00000000000000/* * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import java.io.Serializable; public class ProfilerConfig implements Serializable { private static final long serialVersionUID = -5105358164257442449L; private final String klass; private final String opts; public ProfilerConfig(String klass, String opts) { this.klass = klass; this.opts = opts; } public ProfilerConfig(String klass) { this.klass = klass; this.opts = ""; } public String getKlass() { return klass; } public String getOpts() { return opts; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ProfilerConfig that = (ProfilerConfig) o; if (!klass.equals(that.klass)) return false; if (!opts.equals(that.opts)) return false; return true; } @Override public int hashCode() { int result = klass.hashCode(); result = 31 * result + opts.hashCode(); return result; } @Override public String toString() { return klass + ":" + opts; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ThreadsValueConverter.java000066400000000000000000000040361446271450100315160ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import joptsimple.ValueConverter; import org.openjdk.jmh.annotations.Threads; /** * Converts {@link String} value to {@link Integer} and uses {@link Threads#MAX} if {@code max} string was given. */ public class ThreadsValueConverter implements ValueConverter { public static final ValueConverter INSTANCE = new ThreadsValueConverter(); @Override public Integer convert(String value) { if (value.equalsIgnoreCase("max")) { return Threads.MAX; } return IntegerValueConverter.POSITIVE.convert(value); } @Override public Class valueType() { return IntegerValueConverter.POSITIVE.valueType(); } @Override public String valuePattern() { return IntegerValueConverter.POSITIVE.valuePattern(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/TimeValue.java000066400000000000000000000143201446271450100271270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import java.io.Serializable; import java.util.concurrent.TimeUnit; /** * A generic time scalar. */ public class TimeValue implements Serializable { private static final long serialVersionUID = 1L; public static final TimeValue NONE = new TimeValue(0, TimeUnit.SECONDS); public static TimeValue days(long v) { return new TimeValue(v, TimeUnit.DAYS); } public static TimeValue hours(long v) { return new TimeValue(v, TimeUnit.HOURS); } public static TimeValue microseconds(long v) { return new TimeValue(v, TimeUnit.MICROSECONDS); } public static TimeValue milliseconds(long v) { return new TimeValue(v, TimeUnit.MILLISECONDS); } public static TimeValue minutes(long v) { return new TimeValue(v, TimeUnit.MINUTES); } public static TimeValue nanoseconds(long v) { return new TimeValue(v, TimeUnit.NANOSECONDS); } public static TimeValue seconds(long v) { return new TimeValue(v, TimeUnit.SECONDS); } private final long time; private final TimeUnit timeUnit; public TimeValue(long time, TimeUnit timeUnit) { if (time < 0) { throw new IllegalArgumentException("Time should be greater or equal to zero: " + time); } this.time = time; this.timeUnit = timeUnit; } public long getTime() { return time; } public long convertTo(TimeUnit tu) { return tu.convert(time, timeUnit); } public TimeUnit getTimeUnit() { return timeUnit; } @Override public int hashCode() { int hash = 3; hash = 41 * hash + (int) (this.time ^ (this.time >>> 32)); hash = 41 * hash + (this.timeUnit != null ? this.timeUnit.hashCode() : 0); return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final TimeValue other = (TimeValue) obj; if (this.time != other.time) { return false; } if (this.timeUnit != other.timeUnit) { return false; } return true; } @Override public String toString() { if (time == 0) { return "single-shot"; } else { return time + " " + tuToString(timeUnit); } } /** * Converts timeunit to stringly representation. * * @param timeUnit timeunit to convert * @return string representation */ public static String tuToString(TimeUnit timeUnit) { switch (timeUnit) { case DAYS: return "day"; case HOURS: return "hr"; case MICROSECONDS: return "us"; case MILLISECONDS: return "ms"; case MINUTES: return "min"; case NANOSECONDS: return "ns"; case SECONDS: return "s"; default: return "?"; } } /** * Parses time value from a string representation. * This method is called by joptsimple to resolve string values. * @param timeString string representation of a time value * @return TimeValue value */ public static TimeValue valueOf(String timeString) { return fromString(timeString); } public static TimeValue fromString(String timeString) { if (timeString == null) { throw new IllegalArgumentException("String is null"); } timeString = timeString.replaceAll(" ", "").toLowerCase(); if (timeString.contains("ns")) { return new TimeValue(Integer.parseInt(timeString.substring(0, timeString.indexOf("ns"))), TimeUnit.NANOSECONDS); } if (timeString.contains("ms")) { return new TimeValue(Integer.parseInt(timeString.substring(0, timeString.indexOf("ms"))), TimeUnit.MILLISECONDS); } if (timeString.contains("us")) { return new TimeValue(Integer.parseInt(timeString.substring(0, timeString.indexOf("us"))), TimeUnit.MICROSECONDS); } if (timeString.contains("s")) { return new TimeValue(Integer.parseInt(timeString.substring(0, timeString.indexOf("s"))), TimeUnit.SECONDS); } if (timeString.contains("m")) { return new TimeValue(Integer.parseInt(timeString.substring(0, timeString.indexOf("m"))), TimeUnit.MINUTES); } if (timeString.contains("hr")) { return new TimeValue(Integer.parseInt(timeString.substring(0, timeString.indexOf("hr"))), TimeUnit.HOURS); } if (timeString.contains("day")) { return new TimeValue(Integer.parseInt(timeString.substring(0, timeString.indexOf("day"))), TimeUnit.DAYS); } return new TimeValue(Integer.parseInt(timeString), TimeUnit.SECONDS); } public void sleep() throws InterruptedException { timeUnit.sleep(time); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/VerboseMode.java000066400000000000000000000031751446271450100274540ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; public enum VerboseMode { /** * Be completely silent. */ SILENT(0), /** * Output normally. */ NORMAL(1), /** * Output extra info. */ EXTRA(2), ; private final int level; VerboseMode(int level) { this.level = level; } public boolean equalsOrHigherThan(VerboseMode other) { return level >= other.level; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/runner/options/WarmupMode.java000066400000000000000000000036461446271450100273250ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; /** * Warmup Mode enum */ public enum WarmupMode { /** * Do the individual warmup for every benchmark */ INDI(false, true), /** * Do the bulk warmup before any benchmark starts. */ BULK(true, false), /** * Do the bulk warmup before any benchmark starts, * and then also do individual warmups for every * benchmark. */ BULK_INDI(true, true), ; private final boolean bulk; private final boolean indi; WarmupMode(boolean bulk, boolean indi) { this.bulk = bulk; this.indi = indi; } public boolean isBulk() { return bulk; } public boolean isIndi() { return indi; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/000077500000000000000000000000001446271450100223425ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/AbstractStatistics.java000066400000000000000000000070431446271450100270270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.apache.commons.math3.distribution.TDistribution; import org.apache.commons.math3.stat.inference.TestUtils; public abstract class AbstractStatistics implements Statistics { private static final long serialVersionUID = 1536835581997509117L; /** * Returns the interval c1, c2 of which there's an 1-alpha * probability of the mean being within the interval. * * @param confidence level * @return the confidence interval */ @Override public double[] getConfidenceIntervalAt(double confidence) { double[] interval = new double[2]; if (getN() <= 2) { interval[0] = interval[1] = Double.NaN; return interval; } TDistribution tDist = new TDistribution(getN() - 1); double a = tDist.inverseCumulativeProbability(1 - (1 - confidence) / 2); interval[0] = getMean() - a * getStandardDeviation() / Math.sqrt(getN()); interval[1] = getMean() + a * getStandardDeviation() / Math.sqrt(getN()); return interval; } @Override public boolean isDifferent(Statistics other, double confidence) { return TestUtils.tTest(this, other, 1 - confidence); } @Override public double getMeanErrorAt(double confidence) { if (getN() <= 2) return Double.NaN; TDistribution tDist = new TDistribution(getN() - 1); double a = tDist.inverseCumulativeProbability(1 - (1 - confidence) / 2); return a * getStandardDeviation() / Math.sqrt(getN()); } @Override public String toString() { return "N:" + getN() + " Mean: " + getMean() + " Min: " + getMin() + " Max: " + getMax() + " StdDev: " + getStandardDeviation(); } @Override public double getMean() { if (getN() > 0) { return getSum() / getN(); } else { return Double.NaN; } } @Override public double getStandardDeviation() { return Math.sqrt(getVariance()); } @Override public int compareTo(Statistics other, double confidence) { if (isDifferent(other, confidence)) { return Double.compare(getMean(), other.getMean()); } else { return 0; } } @Override public int compareTo(Statistics other) { return compareTo(other, 0.99); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/BoundedPriorityQueue.java000066400000000000000000000077351446271450100273500ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.Serializable; import java.util.*; /** * Bounded variant of {@link PriorityQueue}. * Note: elements are returned in reverse order. * For instance, if "top N smallest elements" are required, use {@code new BoundedPriorityQueue(N)}, * and the elements would be returned in largest to smallest order. * * @param type of the element */ public class BoundedPriorityQueue extends AbstractQueue implements Serializable { private static final long serialVersionUID = 7159618773497127413L; private final int maxSize; private final Comparator comparator; private final Queue queue; /** * Creates a bounded priority queue with the specified maximum size and default ordering. * At most {@code maxSize} smallest elements would be kept in the queue. * * @param maxSize maximum size of the queue */ public BoundedPriorityQueue(int maxSize) { this(maxSize, null); } /** * Creates a bounded priority queue with the specified maximum size. * At most {@code maxSize} smallest elements would be kept in the queue. * * @param maxSize maximum size of the queue * @param comparator comparator that orders the elements */ public BoundedPriorityQueue(int maxSize, Comparator comparator) { this.maxSize = maxSize; this.comparator = reverse(comparator); this.queue = new PriorityQueue<>(10, this.comparator); } /** * Internal queue should be in fact in reverse order. * By default, the queue aims for "top N smallest elements". * So peek() should return the biggest element, so it can be removed when adding smaller element * * @param comparator comparator that designates ordering of the entries or {@code null} for default ordering * @param type of the element * @return reverse comparator */ private static Comparator reverse(Comparator comparator) { if (comparator == null) { return Collections.reverseOrder(); } return Collections.reverseOrder(comparator); } @Override public boolean add(E e) { return offer(e); } @Override public boolean offer(E e) { if (queue.size() >= maxSize) { E head = peek(); if (comparator.compare(e, head) < 1) { return false; } poll(); } return queue.offer(e); } @Override public E poll() { return queue.poll(); } @Override public E peek() { return queue.peek(); } @Override public Iterator iterator() { return queue.iterator(); } @Override public int size() { return queue.size(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java000066400000000000000000000135041446271450100252760ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.File; import java.io.IOException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; /** * A utility class for loading classes in various ways. */ public class ClassUtils { private static final boolean USE_SEPARATE_CLASSLOADER = Boolean.getBoolean("jmh.separateClassLoader"); // Static access only private ClassUtils() { } /** * Enumerates all methods in hierarchy. Note that is different from both Class.getDeclaredMethods() and * Class.getMethods(). * * @param clazz class to enumerate. * @return list of methods. */ public static List enumerateMethods(Class clazz) { List result = new ArrayList<>(); Class current = clazz; while (current != null) { result.addAll(Arrays.asList(current.getDeclaredMethods())); current = current.getSuperclass(); } return result; } public static Class loadClass(String className) { try { if (!USE_SEPARATE_CLASSLOADER) { return Class.forName(className); } // Load the class in a different classloader String classPathValue = System.getProperty("java.class.path"); String[] classPath = classPathValue.split(File.pathSeparator); URL[] classPathUrl = new URL[classPath.length]; for (int i = 0; i < classPathUrl.length; i++) { try { classPathUrl[i] = new File(classPath[i]).toURI().toURL(); } catch (MalformedURLException ex) { throw new IllegalStateException("Error parsing the value of property java.class.path: " + classPathValue, ex); } } try (URLClassLoader loader = new URLClassLoader(classPathUrl)) { return loader.loadClass(className); } catch (IOException e) { throw new IllegalStateException(e); } } catch (ClassNotFoundException ex) { throw new IllegalArgumentException("Benchmark does not match a class", ex); } } /** * Make the collection of class names denser. * * @param src source class names * @return map of [src class name, denser class name] */ public static Map denseClassNames(Collection src) { if (src.isEmpty()) return Collections.emptyMap(); int maxLen = Integer.MIN_VALUE; for (String s : src) { maxLen = Math.max(maxLen, s.length()); } boolean first = true; boolean prefixCut = false; String[] prefix = new String[0]; for (String s : src) { String[] names = s.split("\\."); if (first) { prefix = new String[names.length]; int c; for (c = 0; c < names.length; c++) { if (names[c].toLowerCase().equals(names[c])) { prefix[c] = names[c]; } else { break; } } prefix = Arrays.copyOf(prefix, c); first = false; continue; } int c = 0; while (c < Math.min(prefix.length, names.length)) { String n = names[c]; String p = prefix[c]; if (!n.equals(p) || !n.toLowerCase().equals(n)) { break; } c++; } if (prefix.length != c) { prefixCut = true; } prefix = Arrays.copyOf(prefix, c); } for (int c = 0; c < prefix.length; c++) { prefix[c] = prefixCut ? String.valueOf(prefix[c].charAt(0)) : ""; } Map result = new HashMap<>(); for (String s : src) { int prefixLen = prefix.length; String[] names = s.split("\\."); System.arraycopy(prefix, 0, names, 0, prefixLen); String dense = ""; for (String n : names) { if (!n.isEmpty()) { dense += n + "."; } } if (dense.endsWith(".")) { dense = dense.substring(0, dense.length() - 1); } result.put(s, dense); } return result; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/CountingMap.java000066400000000000000000000032541446271450100254350ustar00rootroot00000000000000/* * Copyright (c) 2022, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.util.HashMap; import java.util.Map; public class CountingMap { final Map map = new HashMap<>(); public int incrementAndGet(K k) { MutableInt mi = map.get(k); if (mi == null) { mi = new MutableInt(); map.put(k, mi); } return mi.incrementAndGet(); } private static class MutableInt { int value; int incrementAndGet() { return ++value; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/Deduplicator.java000066400000000000000000000031621446271450100256260ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; public class Deduplicator { final ConcurrentMap map; public Deduplicator() { map = new ConcurrentHashMap<>(); } public T dedup(T t) { T et = map.putIfAbsent(t, t); if (et != null) { return et; } else { return t; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/DelegatingMultimap.java000066400000000000000000000072331446271450100267660ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Map; public class DelegatingMultimap implements Multimap, Serializable { private static final long serialVersionUID = 7026540942232962263L; protected final Map> map; public DelegatingMultimap(Map> map) { this.map = map; } protected Collection createValueCollection() { return new ArrayList<>(); } @Override public void put(K key, V value) { Collection vs = map.get(key); if (vs == null) { vs = createValueCollection(); map.put(key, vs); } vs.add(value); } @Override public void putAll(K key, Collection vvs) { Collection vs = map.get(key); if (vs == null) { vs = createValueCollection(); map.put(key, vs); } vs.addAll(vvs); } @Override public Collection get(K key) { Collection vs = map.get(key); return (vs == null) ? Collections.emptyList() : Collections.unmodifiableCollection(vs); } @Override public boolean isEmpty() { return map.isEmpty(); } @Override public void clear() { map.clear(); } @Override public Collection keys() { return map.keySet(); } @Override public Collection values() { Collection result = createValueCollection(); for (Collection vs : map.values()) { result.addAll(vs); } return result; } public Collection>> entrySet() { return map.entrySet(); } @Override public void remove(K key) { map.remove(key); } @Override public void merge(Multimap other) { for (K k : other.keys()) { putAll(k, other.get(k)); } } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; @SuppressWarnings("unchecked") DelegatingMultimap that = (DelegatingMultimap) o; if (!map.equals(that.map)) return false; return true; } @Override public int hashCode() { return map.hashCode(); } @Override public String toString() { return map.toString(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/DelegatingMultiset.java000066400000000000000000000062131446271450100270010ustar00rootroot00000000000000/* * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.Map; public class DelegatingMultiset implements Multiset, Serializable { private static final long serialVersionUID = -8454789908011859615L; protected final Map map; private long size; public DelegatingMultiset(Map map) { this.map = map; } @Override public void add(T element) { add(element, 1); } @Override public void add(T element, long add) { Long count = map.get(element); if (count == null) { count = 0L; } count += add; size += add; if (count != 0) { map.put(element, count); } else { map.remove(element); } } @Override public long count(T element) { Long count = map.get(element); return (count == null) ? 0 : count; } @Override public Collection> entrySet() { return map.entrySet(); } @Override public boolean isEmpty() { return map.isEmpty(); } @Override public long size() { return size; } @Override public Collection keys() { return Collections.unmodifiableCollection(map.keySet()); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; @SuppressWarnings("unchecked") DelegatingMultiset that = (DelegatingMultiset) o; if (size != that.size) return false; if (!map.equals(that.map)) return false; return true; } @Override public int hashCode() { int result = map.hashCode(); result = 31 * result + (int) (size ^ (size >>> 32)); return result; } @Override public void clear() { size = 0; map.clear(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java000066400000000000000000000177561446271450100251250ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.*; import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; import java.util.List; /** * A utility class for File creation and manipulation. */ public class FileUtils { // Static access only private FileUtils() { } static final TempFileManager TEMP_FILE_MANAGER = new TempFileManager(); /** * Creates the temp file, and retains it as long as the reference to it * is reachable. * * @param suffix suffix * @return temp file * @throws IOException if things go crazy */ public static TempFile weakTempFile(String suffix) throws IOException { return TEMP_FILE_MANAGER.create(suffix); } public static void purgeTemps() { TEMP_FILE_MANAGER.purge(); } /** * Creates the temp file with given suffix. The file would be removed * on JVM exit, or when caller deletes the file itself. * * @param suffix suffix * @return temporary file * @throws IOException if things go crazy */ public static File tempFile(String suffix) throws IOException { File file = File.createTempFile("jmh", suffix); file.deleteOnExit(); return file; } /** * Helper method for extracting a given resource to File * * @param name name of the resource * @return a File pointing to the extracted resource * @throws IOException if things go crazy */ public static File extractFromResource(String name) throws IOException { File temp = FileUtils.tempFile("extracted"); try (InputStream fis = FileUtils.class.getResourceAsStream(name); OutputStream fos = new FileOutputStream(temp)) { byte[] buf = new byte[8192]; int read; while ((read = fis.read(buf)) != -1) { fos.write(buf, 0, read); } fos.close(); return temp; } } /** * Create a temporary file (see {@link File#createTempFile(String, String)}) and fill it with the given lines. * * @param suffix file suffix {@link File#createTempFile(String, String)} * @param lines to be written * * @return the temporary file absolute path * @throws IOException on file creation error */ public static String createTempFileWithLines(String suffix, Iterable lines) throws IOException { File file = FileUtils.tempFile(suffix); PrintWriter pw = new PrintWriter(file); for (String l : lines) { pw.println(l); } pw.close(); return file.getAbsolutePath(); } public static Collection tail(File file, int num) throws IOException { try (FileInputStream fis = new FileInputStream(file); InputStreamReader is = new InputStreamReader(fis); BufferedReader reader = new BufferedReader(is)) { LinkedList lines = new LinkedList<>(); String line; while ((line = reader.readLine()) != null) { lines.add(line); if (lines.size() > num) { lines.remove(0); } } return lines; } } public static Collection readAllLines(Reader src) throws IOException { BufferedReader reader = new BufferedReader(src); List lines = new ArrayList<>(); String line; while ((line = reader.readLine()) != null) { lines.add(line); } return lines; } public static Collection readAllLines(File file) throws IOException { try (FileReader fr = new FileReader(file)) { return readAllLines(fr); } } public static Collection readAllLines(InputStream stream) throws IOException { try (InputStreamReader reader = new InputStreamReader(stream)) { return readAllLines(reader); } finally { FileUtils.safelyClose(stream); } } public static void writeLines(File file, Collection lines) throws IOException { try (PrintWriter pw = new PrintWriter(file)) { for (String line : lines) { pw.println(line); } } } public static void appendLines(File file, Collection lines) throws IOException { Collection newLines = new ArrayList<>(); try { newLines.addAll(readAllLines(file)); } catch (IOException e) { // no file } newLines.addAll(lines); writeLines(file, newLines); } public static Collection getClasses(File root) { Collection result = new ArrayList<>(); List newDirs = new ArrayList<>(); newDirs.add(root); while (!newDirs.isEmpty()) { List add = new ArrayList<>(); for (File dir : newDirs) { File[] files = dir.listFiles(); if (files != null) { for (File f : files) { if (f.isDirectory()) { add.add(f); } else { if (f.getName().endsWith(".class")) { result.add(f); } } } } } newDirs.clear(); newDirs = add; } return result; } public static void copy(String src, String dst) throws IOException { try (FileInputStream fis = new FileInputStream(src); FileOutputStream fos = new FileOutputStream(dst)) { byte[] buf = new byte[8192]; int read; while ((read = fis.read(buf)) != -1) { fos.write(buf, 0, read); } } } public static void safelyClose(T obj) { if (obj != null) { try { obj.flush(); } catch (IOException e) { // ignore } try { obj.close(); } catch (IOException e) { // ignore } } } public static void safelyClose(T obj) { if (obj != null) { try { obj.close(); } catch (IOException e) { // do nothing } } } public static void touch(String f) throws IOException { File file = new File(f); try { if (file.createNewFile() || file.canWrite()) { return; } } catch (IOException e) { // fall-through } throw new IOException("The file is not writable: " + f); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/HashMultimap.java000066400000000000000000000030301446271450100255750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.Serializable; import java.util.Collection; import java.util.HashMap; public class HashMultimap extends DelegatingMultimap implements Serializable { private static final long serialVersionUID = 2484428623123444998L; public HashMultimap() { super(new HashMap<>()); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/HashMultiset.java000066400000000000000000000027651446271450100256310ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.Serializable; import java.util.HashMap; public class HashMultiset extends DelegatingMultiset implements Serializable { private static final long serialVersionUID = 8149201968248505516L; public HashMultiset() { super(new HashMap<>()); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/HashsetMultimap.java000066400000000000000000000032441446271450100263200ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; public class HashsetMultimap extends DelegatingMultimap implements Serializable { private static final long serialVersionUID = -4236100656731956836L; public HashsetMultimap() { super(new HashMap<>()); } @Override protected Collection createValueCollection() { return new HashSet<>(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/InputStreamDrainer.java000066400000000000000000000062321446271450100267700ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** * Will drain the output stream. */ public final class InputStreamDrainer extends Thread { private static final int BUF_SIZE = 1024; private final List outs; private final InputStream in; /** * Create a drainer which will discard the read lines. * * @param in The input stream to drain */ public InputStreamDrainer(InputStream in) { this(in, null); } /** * Create a drainer that will echo all read lines to out. * * @param in The input stream to drain * @param out Where to drain the stream into */ public InputStreamDrainer(InputStream in, OutputStream out) { this.in = in; this.outs = new ArrayList<>(); addOutputStream(out); } /** * Adds an output stream to drain the output to. * * @param out The output stream */ public void addOutputStream(OutputStream out) { if (out != null) { outs.add(out); } } /** Drain the stream. */ public void run() { byte[] buf = new byte[BUF_SIZE]; try { int read; while ((read = in.read(buf)) != -1) { for (OutputStream out : outs) { out.write(buf, 0, read); } } for (OutputStream out : outs) { out.flush(); } } catch (IOException ioe) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, ioe.getMessage(), ioe); } finally { try { in.close(); } catch (IOException ioe) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, ioe.getMessage(), ioe); } } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/Interval.java000066400000000000000000000043141446271450100247730ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; public class Interval implements Comparable { public final long src; public final long dst; public Interval(long src, long dst) { this.src = src; this.dst = dst; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Interval interval = (Interval) o; if (dst != interval.dst) return false; if (src != interval.src) return false; return true; } @Override public int hashCode() { int result = (int) (src ^ (src >>> 32)); result = 31 * result + (int) (dst ^ (dst >>> 32)); return result; } @Override public int compareTo(Interval o) { int c1 = Long.compare(src, o.src); if (c1 != 0) { return c1; } return Long.compare(dst, o.dst); } @Override public String toString() { return "[" + src + ", " + dst + "]"; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/IntervalMap.java000066400000000000000000000062361446271450100254360ustar00rootroot00000000000000/* * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.util.SortedMap; import java.util.TreeMap; public class IntervalMap { static final class Interval implements Comparable { final long from, to; public Interval(long from, long to) { this.from = from; this.to = to; } @Override public int compareTo(Interval other) { return Long.compare(from, other.from); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (int) (from ^ (from >>> 32)); return result; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Interval other = (Interval) obj; if (from != other.from) { return false; } return true; } } final SortedMap from; public IntervalMap() { from = new TreeMap<>(); } public void add(T val, long from, long to) { // TODO: Check for intersections this.from.put(new Interval(from, to), val); } public T get(long k) { Interval i = new Interval(k, k); T key = from.get(i); if (key != null) { return key; } SortedMap head = from.headMap(i); if (head.isEmpty()) { return null; } else { Interval last = head.lastKey(); if (k >= last.from && k < last.to) { return from.get(last); // Interval from..to contains k } else { return null; } } } public void merge(IntervalMap other) { from.putAll(other.from); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/JDKVersion.java000066400000000000000000000042511446271450100251650ustar00rootroot00000000000000/* * Copyright (c) 2020, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; public class JDKVersion { public static int parseMajor(String version) { version = version.toLowerCase(); int dotIdx = version.indexOf("."); if (dotIdx != -1) { try { return Integer.parseInt(version.substring(0, dotIdx)); } catch (Exception e) { return -1; } } int dashIdx = version.indexOf("-"); if (dashIdx != -1) { try { return Integer.parseInt(version.substring(0, dashIdx)); } catch (Exception e) { return -1; } } int uIdx = version.indexOf("u"); if (uIdx != -1) { try { return Integer.parseInt(version.substring(0, uIdx)); } catch (Exception e) { return -1; } } try { return Integer.parseInt(version); } catch (Exception e) { return -1; } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java000066400000000000000000000122711446271450100261760ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.apache.commons.math3.stat.descriptive.rank.Percentile; import java.util.AbstractMap; import java.util.Arrays; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; /** * Calculate statistics over a list of doubles. */ public class ListStatistics extends AbstractStatistics { private static final long serialVersionUID = -90642978235578197L; private double[] values; private int count; public ListStatistics() { values = new double[0]; count = 0; } public ListStatistics(double[] samples) { this(); for (double d : samples) { addValue(d); } } public ListStatistics(long[] samples) { this(); for (long l : samples) { addValue((double) l); } } public void addValue(double d) { if (count >= values.length) { values = Arrays.copyOf(values, Math.max(1, values.length << 1)); } values[count] = d; count++; } @Override public double getMax() { if (count > 0) { double m = Double.NEGATIVE_INFINITY; for (int i = 0; i < count; i++) { m = Math.max(m, values[i]); } return m; } else { return Double.NaN; } } @Override public double getMin() { if (count > 0) { double m = Double.POSITIVE_INFINITY; for (int i = 0; i < count; i++) { m = Math.min(m, values[i]); } return m; } else { return Double.NaN; } } @Override public long getN() { return count; } @Override public double getSum() { if (count > 0) { double s = 0; for (int i = 0; i < count; i++) { s += values[i]; } return s; } else { return Double.NaN; } } @Override public double getPercentile(double rank) { if (count == 0) { return Double.NaN; } if (rank == 0) { return getMin(); } // trim values = Arrays.copyOf(values, count); Percentile p = new Percentile(); return p.evaluate(values, rank); } @Override public int[] getHistogram(double[] levels) { if (levels.length < 2) { throw new IllegalArgumentException("Expected more than two levels"); } double[] vs = Arrays.copyOf(values, count); Arrays.sort(vs); int[] result = new int[levels.length - 1]; int c = 0; values: for (double v : vs) { while (levels[c] > v || v >= levels[c + 1]) { c++; if (c > levels.length - 2) break values; } result[c]++; } return result; } @Override public Iterator> getRawData() { return new ListStatisticsIterator(); } @Override public double getVariance() { if (count > 1) { double v = 0; double m = getMean(); for (int i = 0; i < count; i++) { v += Math.pow(values[i] - m, 2); } return v / (count - 1); } else { return Double.NaN; } } private class ListStatisticsIterator implements Iterator> { private int currentIndex = 0; @Override public boolean hasNext() { return currentIndex < count; } @Override public Map.Entry next() { if (!hasNext()) { throw new NoSuchElementException("No more elements."); } return new AbstractMap.SimpleImmutableEntry<>(values[currentIndex++], 1L); } @Override public void remove() { throw new UnsupportedOperationException("Element cannot be removed."); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/Multimap.java000066400000000000000000000045261446271450100250040ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.util.Collection; import java.util.Map; /** * Basic Multimap. * * @param key type * @param value type */ public interface Multimap { /** * Put the element pair. * * @param key key * @param value value */ void put(K key, V value); /** * Put multiple pairs. * @param k key * @param vs values */ void putAll(K k, Collection vs); /** * Get all values associated with the key * @param key key * @return collection of values */ Collection get(K key); /** * Get all associations of the multimap. * The method is intended for read-only view. * @return entry set of the multimap */ Collection>> entrySet(); /** * Checks if multimap is empty * @return true, if empty */ boolean isEmpty(); /** * Clears the multimap */ void clear(); /** * Keys in the map * @return collection of keys */ Collection keys(); Collection values(); void remove(K key); void merge(Multimap other); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/Multiset.java000066400000000000000000000050331446271450100250140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.util.Collection; import java.util.Map; /** * Basic Multiset. * * (Transitional interface) * * @param element type */ public interface Multiset { /** * Add the element to the multiset * @param element element to add */ void add(T element); /** * Add the element to the multiset * @param element element to add * @param count number of elements to add */ void add(T element, long count); /** * Count the elements in multiset * @param element element * @return number of matching elements in the set; zero, if no elements */ long count(T element); /** * Get all associations of the multiset. * Each entry provides a key and a count of that element. * @return entry set of the multiset */ Collection> entrySet(); /** * Answers if Multiset is empty * @return true, if set is empty */ boolean isEmpty(); /** * Answers the size of multiset. * Equivalent to number of elements, counting duplications. * * @return number of elements */ long size(); /** * Answers the collection of keys * @return the collections of keys */ Collection keys(); /** * Remove all the elements. */ void clear(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java000066400000000000000000000105701446271450100270710ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.util.*; public class MultisetStatistics extends AbstractStatistics { private static final long serialVersionUID = -4401871054963903938L; private final Multiset values; public MultisetStatistics() { values = new TreeMultiset<>(); } public void addValue(double d, long count) { values.add(d, count); } @Override public double getMax() { if (!values.isEmpty()) { double max = Double.NEGATIVE_INFINITY; for (double d : values.keys()) { max = Math.max(max, d); } return max; } else { return Double.NaN; } } @Override public double getMin() { if (!values.isEmpty()) { double min = Double.POSITIVE_INFINITY; for (double d : values.keys()) { min = Math.min(min, d); } return min; } else { return Double.NaN; } } @Override public long getN() { return values.size(); } @Override public double getSum() { if (!values.isEmpty()) { double sum = 0; for (double d : values.keys()) { sum += d * values.count(d); } return sum; } else { return Double.NaN; } } private double get(long index) { long cur = 0; for (double d : values.keys()) { cur += values.count(d); if (cur >= index) return d; } return getMax(); } @Override public double getPercentile(double rank) { if (rank < 0.0d || rank > 100.0d) throw new IllegalArgumentException("Rank should be within [0; 100]"); if (rank == 0.0d) { return getMin(); } double pos = rank * (values.size() + 1) / 100; double floorPos = Math.floor(pos); double flooredValue = get((long) floorPos); double nextValue = get((long) floorPos + 1); return flooredValue + (nextValue - flooredValue) * (pos - floorPos); } @Override public double getVariance() { if (getN() > 0) { double v = 0; double m = getMean(); for (double d : values.keys()) { v += Math.pow(d - m, 2) * values.count(d); } return v / (getN() - 1); } else { return Double.NaN; } } @Override public int[] getHistogram(double[] levels) { if (levels.length < 2) { throw new IllegalArgumentException("Expected more than two levels"); } List vs = new ArrayList<>(values.keys()); Collections.sort(vs); int[] result = new int[levels.length - 1]; int c = 0; values: for (double v : vs) { while (levels[c] > v || v >= levels[c + 1]) { c++; if (c > levels.length - 2) break values; } result[c] += values.count(v); } return result; } @Override public Iterator> getRawData() { return values.entrySet().iterator(); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/Multisets.java000066400000000000000000000040441446271450100252000ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.util.*; public class Multisets { public static List countHighest(Multiset set, int top) { Queue> q = new BoundedPriorityQueue<>(top, Map.Entry.comparingByValue().reversed()); q.addAll(set.entrySet()); List result = new ArrayList<>(q.size()); Map.Entry pair; while ((pair = q.poll()) != null) { result.add(pair.getKey()); } // BoundedPriorityQueue returns "smallest to largest", so we reverse the result Collections.reverse(result); return result; } public static List sortedDesc(final Multiset set) { List sorted = new ArrayList<>(set.keys()); sorted.sort((o1, o2) -> Long.compare(set.count(o2), set.count(o1))); return sorted; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/NullOutputStream.java000066400000000000000000000030251446271450100265140ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.OutputStream; public class NullOutputStream extends OutputStream { @Override public void write(byte[] b) { // drop } @Override public void write(byte[] b, int off, int len) { // drop } @Override public void write(int b) { // drop } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java000066400000000000000000000065771446271450100250110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.Serializable; import java.util.Objects; import java.util.function.Supplier; /** * Option class * @param stored value. */ public class Optional implements Serializable { private static final long serialVersionUID = 5691070564925468961L; private final T val; private Optional(T val) { if (val == null) { throw new IllegalArgumentException("Val can not be null"); } this.val = val; } private Optional() { this.val = null; } public T orElse(T elseVal) { return (val == null) ? elseVal : val; } public T orElseGet(Supplier alternativeSupplier) { return (val == null) ? alternativeSupplier.get() : val; } public Optional orAnother(Optional alternative) { return (val == null) ? alternative : this; } /** * Produce empty Option * @param type * @return empty option */ public static Optional none() { return new Optional<>(); } /** * Wrap the existing value in Option. * @param val value to wrap * @param type * @return option with value */ public static Optional of(T val) { return new Optional<>(val); } public static Optional eitherOf(T val) { if (val == null) { return Optional.none(); } else { return Optional.of(val); } } public boolean hasValue() { return val != null; } public String toString() { if (val == null) { return "[]"; } else { return "[" + val + "]"; } } public T get() { if (val == null) { throw new IllegalStateException("Optional is null"); } return val; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Optional optional = (Optional) o; if (!Objects.equals(val, optional.val)) return false; return true; } @Override public int hashCode() { return val != null ? val.hashCode() : 0; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/SampleBuffer.java000066400000000000000000000070711446271450100255650ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.Serializable; /** * Sampling buffer accepts samples. */ public class SampleBuffer implements Serializable { private static final long serialVersionUID = 6124923853916845327L; private static final int PRECISION_BITS = 10; private static final int BUCKETS = Long.SIZE - PRECISION_BITS; private final int[][] hdr; public SampleBuffer() { hdr = new int[BUCKETS][]; } public void half() { for (int[] bucket : hdr) { if (bucket != null) { for (int j = 0; j < bucket.length; j++) { int nV = bucket[j] / 2; if (nV != 0) { // prevent halving to zero bucket[j] = nV; } } } } } public void add(long sample) { int bucket = Math.max(0, BUCKETS - Long.numberOfLeadingZeros(sample)); int subBucket = (int) (sample >> bucket); int[] b = hdr[bucket]; if (b == null) { b = new int[1 << PRECISION_BITS]; hdr[bucket] = b; } b[subBucket]++; } public Statistics getStatistics(double multiplier) { MultisetStatistics stat = new MultisetStatistics(); for (int i = 0; i < hdr.length; i++) { int[] bucket = hdr[i]; if (bucket != null) { for (int j = 0; j < bucket.length; j++) { long ns = (long) j << i; stat.addValue(multiplier * ns, bucket[j]); } } } return stat; } public void addAll(SampleBuffer other) { for (int i = 0; i < other.hdr.length; i++) { int[] otherBucket = other.hdr[i]; if (otherBucket != null) { int[] myBucket = hdr[i]; if (myBucket == null) { myBucket = new int[1 << PRECISION_BITS]; hdr[i] = myBucket; } for (int j = 0; j < otherBucket.length; j++) { myBucket[j] += otherBucket[j]; } } } } public int count() { int count = 0; for (int[] bucket : hdr) { if (bucket != null) { for (int v : bucket) { count += v; } } } return count; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/ScoreFormatter.java000066400000000000000000000071031446271450100261450ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; public class ScoreFormatter { private static final int PRECISION = Integer.getInteger("jmh.scorePrecision", 3); private static final double ULP = 1.0 / Math.pow(10, PRECISION); private static final double THRESHOLD = ULP / 2; public static boolean isApproximate(double score) { return (score < THRESHOLD); } public static String format(double score) { if (isApproximate(score)) { int power = (int) Math.round(Math.log10(score)); return "\u2248 " + ((power != 0) ? "10" + superscript("" + power) : "0"); } else { return String.format("%." + PRECISION + "f", score); } } public static String format(int width, double score) { if (isApproximate(score)) { int power = (int) Math.round(Math.log10(score)); return String.format("%" + width + "s", "\u2248 " + ((power != 0) ? "10" + superscript("" + power) : "0")); } else { return String.format("%" + width + "." + PRECISION + "f", score); } } public static String formatExact(int width, double score) { return String.format("%" + width + "." + PRECISION + "f", score); } public static String formatLatex(double score) { if (isApproximate(score)) { int power = (int) Math.round(Math.log10(score)); return "$\\approx " + ((power != 0) ? "10^{" + power + "}" : "0") + "$"; } else { return String.format("%." + PRECISION + "f", score); } } public static String formatError(double error) { return String.format("%." + PRECISION + "f", Math.max(error, ULP)); } public static String formatError(int width, double error) { return String.format("%" + width + "." + PRECISION + "f", Math.max(error, ULP)); } public static String superscript(String str) { str = str.replaceAll("-", "\u207b"); str = str.replaceAll("0", "\u2070"); str = str.replaceAll("1", "\u00b9"); str = str.replaceAll("2", "\u00b2"); str = str.replaceAll("3", "\u00b3"); str = str.replaceAll("4", "\u2074"); str = str.replaceAll("5", "\u2075"); str = str.replaceAll("6", "\u2076"); str = str.replaceAll("7", "\u2077"); str = str.replaceAll("8", "\u2078"); str = str.replaceAll("9", "\u2079"); return str; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java000066400000000000000000000063231446271450100272260ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.util.AbstractMap; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; /** * Calculate statistics with just a single value. */ public class SingletonStatistics extends AbstractStatistics { private static final long serialVersionUID = -90642978235578197L; private final double value; public SingletonStatistics(double value) { this.value = value; } @Override public double getMax() { return value; } @Override public double getMin() { return value; } @Override public long getN() { return 1; } @Override public double getSum() { return value; } @Override public double getPercentile(double rank) { return value; } @Override public double getVariance() { return Double.NaN; } @Override public int[] getHistogram(double[] levels) { int[] result = new int[levels.length - 1]; for (int c = 0; c < levels.length - 1; c++) { if (levels[c] <= value && value < levels[c + 1]) { result[c] = 1; break; } } return result; } @Override public Iterator> getRawData() { return new SingletonStatisticsIterator(); } private class SingletonStatisticsIterator implements Iterator> { private boolean entryReturned = false; @Override public boolean hasNext() { return !entryReturned; } @Override public Map.Entry next() { if (entryReturned) { throw new NoSuchElementException("No more elements."); } entryReturned = true; return new AbstractMap.SimpleImmutableEntry<>(value, 1L); } @Override public void remove() { throw new UnsupportedOperationException("Element cannot be removed."); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/Statistics.java000066400000000000000000000115441446271450100253440ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.apache.commons.math3.stat.descriptive.StatisticalSummary; import java.io.Serializable; import java.util.Iterator; import java.util.Map.Entry; public interface Statistics extends Serializable, StatisticalSummary, Comparable { /** * Gets the confidence interval at given confidence level. * @param confidence confidence level (e.g. 0.95) * @return the interval in which mean lies with the given confidence level */ double[] getConfidenceIntervalAt(double confidence); /** * Gets the mean error at given confidence level. * @param confidence confidence level (e.g. 0.95) * @return the mean error with the given confidence level */ double getMeanErrorAt(double confidence); /** * Checks if this statistics statistically different from the given one * with the given confidence level. * @param other statistics to test against * @param confidence confidence level (e.g. 0.95) * @return true, if mean difference is statistically significant */ boolean isDifferent(Statistics other, double confidence); /** * Compares this statistics to another one. * Follows the contract of {@link Comparable}. * * @param other statistics to compare against * @return a negative integer, zero, or a positive integer as this statistics * is less than, equal to, or greater than the specified statistics. */ int compareTo(Statistics other); /** * Compares this statistics to another one. * Follows the contract of {@link Comparable}. * * @param other statistics to compare against * @param confidence confidence level (e.g. 0.99) * @return a negative integer, zero, or a positive integer as this statistics * is less than, equal to, or greater than the specified statistics. */ int compareTo(Statistics other, double confidence); /** * Returns the maximum for this statistics. * @return maximum */ double getMax(); /** * Returns the minimum for this statistics. * @return minimum */ double getMin(); /** * Returns the arithmetic mean for this statistics. * @return arithmetic mean */ double getMean(); /** * Returns the number of samples in this statistics. * @return number of samples */ long getN(); /** * Returns the sum of samples in this statistics. * @return sum */ double getSum(); /** * Returns the standard deviation for this statistics. * @return standard deviation */ double getStandardDeviation(); /** * Returns the variance for this statistics. * @return variance */ double getVariance(); /** * Returns the percentile at given rank. * @param rank the rank, [0..100] * @return percentile */ double getPercentile(double rank); /** * Returns the histogram for this statistics. The histogram bin count would * be equal to number of levels, minus one; so that each i-th bin is the * number of samples in [i-th, (i+1)-th) levels. * * @param levels levels * @return histogram data */ int[] getHistogram(double[] levels); /** * Returns the raw data for this statistics. This data can be useful for * custom postprocessing and statistics computations. Note, that values of * multiple calls may not be unique. Ordering of the values is not specified. * * @return iterator to raw data. Each item is pair of actual value and * number of occurrences of this value. */ Iterator> getRawData(); } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/TempFile.java000066400000000000000000000027761446271450100247260ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.*; public class TempFile { private final File file; public TempFile(File file) { this.file = file; } public void delete() { file.delete(); } public String getAbsolutePath() { return file.getAbsolutePath(); } public File file() { return file; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/TempFileManager.java000066400000000000000000000045551446271450100262160ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.File; import java.io.IOException; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; import java.util.HashSet; import java.util.Set; public class TempFileManager { private final ReferenceQueue rq; private final Set refs; public TempFileManager() { rq = new ReferenceQueue<>(); refs = new HashSet<>(); } public TempFile create(String suffix) throws IOException { purge(); File file = File.createTempFile("jmh", suffix); file.deleteOnExit(); TempFile tf = new TempFile(file); refs.add(new TempFileReference(tf, rq)); return tf; } public void purge() { TempFileReference ref; while ((ref = (TempFileReference) rq.poll()) != null) { if (ref.file != null) { ref.file.delete(); } refs.remove(ref); } } private static class TempFileReference extends WeakReference { final File file; TempFileReference(TempFile referent, ReferenceQueue q) { super(referent, q); file = referent.file(); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/TreeMultimap.java000066400000000000000000000030301446271450100256110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.Serializable; import java.util.Collection; import java.util.TreeMap; public class TreeMultimap extends DelegatingMultimap implements Serializable { private static final long serialVersionUID = 1323519395777393861L; public TreeMultimap() { super(new TreeMap<>()); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/TreeMultiset.java000066400000000000000000000030131446271450100256300ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.Serializable; import java.util.TreeMap; public class TreeMultiset> extends DelegatingMultiset implements Serializable { private static final long serialVersionUID = 3571810468402616517L; public TreeMultiset() { super(new TreeMap<>()); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/UnCloseablePrintStream.java000066400000000000000000000032031446271450100275700ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.OutputStream; import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; public class UnCloseablePrintStream extends PrintStream { public UnCloseablePrintStream(OutputStream out, Charset charset) throws UnsupportedEncodingException { super(out, false, charset.name()); } @Override public void close() { // Do nothing. } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java000066400000000000000000000500661446271450100243140ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import sun.misc.Unsafe; import java.io.*; import java.lang.management.ManagementFactory; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.nio.charset.Charset; import java.util.*; import java.util.concurrent.*; public class Utils { private static final Unsafe U; static { try { Field unsafe = Unsafe.class.getDeclaredField("theUnsafe"); unsafe.setAccessible(true); U = (Unsafe) unsafe.get(null); } catch (NoSuchFieldException | IllegalAccessException e) { throw new IllegalStateException(e); } } private Utils() { } public static > T min(Collection ts) { T min = null; for (T t : ts) { if (min == null) { min = t; } else { min = min.compareTo(t) < 0 ? min : t; } } return min; } public static > T max(Collection ts) { T max = null; for (T t : ts) { if (max == null) { max = t; } else { max = max.compareTo(t) > 0 ? max : t; } } return max; } public static String[] concat(String[] t1, String[] t2) { String[] r = new String[t1.length + t2.length]; System.arraycopy(t1, 0, r, 0, t1.length); System.arraycopy(t2, 0, r, t1.length, t2.length); return r; } public static String join(Collection src, String delim) { StringBuilder sb = new StringBuilder(); boolean first = true; for (String s : src) { if (first) { first = false; } else { sb.append(delim); } sb.append(s); } return sb.toString(); } public static String join(String[] src, String delim) { return join(Arrays.asList(src), delim); } public static Collection splitQuotedEscape(String src) { List results = new ArrayList<>(); StringBuilder sb = new StringBuilder(); boolean escaped = false; for (char ch : src.toCharArray()) { if (ch == ' ' && !escaped) { String s = sb.toString(); if (!s.isEmpty()) { results.add(s); sb = new StringBuilder(); } } else if (ch == '\"') { escaped ^= true; } else { sb.append(ch); } } String s = sb.toString(); if (!s.isEmpty()) { results.add(s); } return results; } public static int sum(int[] arr) { int sum = 0; for (int i : arr) { sum += i; } return sum; } public static int roundUp(int v, int quant) { if ((v % quant) == 0) { return v; } else { return ((v / quant) + 1)*quant; } } public static String throwableToString(Throwable t) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.flush(); pw.close(); return sw.toString(); } public static int[] unmarshalIntArray(String src) { String[] ss = src.split("="); int[] arr = new int[ss.length]; int cnt = 0; for (String s : ss) { arr[cnt] = Integer.parseInt(s.trim()); cnt++; } return arr; } public static String marshalIntArray(int[] arr) { StringBuilder sb = new StringBuilder(); for (int i : arr) { sb.append(i); sb.append("="); } return sb.toString(); } /** * Warm up the CPU schedulers, bring all the CPUs online to get the * reasonable estimate of the system capacity. Some systems, notably embedded Linuxes, * power down the idle CPUs and so availableProcessors() may report lower CPU count * than would be present after the load-up. * * @return max CPU count */ public static int figureOutHotCPUs() { ExecutorService service = Executors.newCachedThreadPool(); int warmupTime = 1000; long lastChange = System.currentTimeMillis(); List> futures = new ArrayList<>(); futures.add(service.submit(new BurningTask())); int max = 0; while (System.currentTimeMillis() - lastChange < warmupTime) { int cur = Runtime.getRuntime().availableProcessors(); if (cur > max) { max = cur; lastChange = System.currentTimeMillis(); futures.add(service.submit(new BurningTask())); } } for (Future f : futures) { f.cancel(true); } service.shutdown(); return max; } private static void setAccessible(Object holder, AccessibleObject o) throws IllegalAccessException { // JDK 9+ has the module protections in place, which would print the warning // to the console if we try setAccessible(true) on inaccessible object. // JDK 16 would deny access by default, so we have no recourse at all. // Try to check with JDK 9+ AccessibleObject.canAccess before doing this // to avoid the confusing console warnings. Force the break in if user asks // explicitly. if (!Boolean.getBoolean("jmh.forceSetAccessible")) { try { Method canAccess = AccessibleObject.class.getDeclaredMethod("canAccess", Object.class); if (!(boolean) canAccess.invoke(o, holder)) { throw new IllegalAccessException(o + " is not accessible"); } } catch (NoSuchMethodException | InvocationTargetException e) { // fall-through } } o.setAccessible(true); } public static Charset guessConsoleEncoding() { // The reason for this method to exist is simple: we need the proper platform encoding for output. // We cannot use Console class directly, because we also need the access to the raw byte stream, // e.g. for pushing in a raw output from a forked VM invocation. Therefore, we are left with // reflectively poking out the Charset from Console, and use it for our own private output streams. // Since JDK 17, there is Console.charset(), which we can use reflectively. // Try 1. Try to poke the System.console(). Console console = System.console(); if (console != null) { try { Method m = Console.class.getDeclaredMethod("charset"); Object res = m.invoke(console); if (res instanceof Charset) { return (Charset) res; } } catch (Exception e) { // fall-through } try { Field f = Console.class.getDeclaredField("cs"); setAccessible(console, f); Object res = f.get(console); if (res instanceof Charset) { return (Charset) res; } } catch (Exception e) { // fall-through } try { Method m = Console.class.getDeclaredMethod("encoding"); setAccessible(console, m); Object res = m.invoke(null); if (res instanceof String) { return Charset.forName((String) res); } } catch (Exception e) { // fall-through } } // Try 2. Try to poke stdout. // When System.console() is null, that is, an application is not attached to a console, the actual // charset of standard output should be extracted from System.out, not from System.console(). // If we indeed have the console, but failed to poll its charset, it is still better to poke stdout. try { PrintStream out = System.out; if (out != null) { Field f = PrintStream.class.getDeclaredField("charOut"); setAccessible(out, f); Object res = f.get(out); if (res instanceof OutputStreamWriter) { String encoding = ((OutputStreamWriter) res).getEncoding(); if (encoding != null) { return Charset.forName(encoding); } } } } catch (Exception e) { // fall-through } // Try 3. Try to poll internal properties. String prop = System.getProperty("sun.stdout.encoding"); if (prop != null) { try { return Charset.forName(prop); } catch (Exception e) { // fall-through } } // Try 4. Nothing left to do, except for returning a (possibly mismatched) default charset. return Charset.defaultCharset(); } public static void reflow(PrintWriter pw, String src, int width, int indent) { StringTokenizer tokenizer = new StringTokenizer(src); int curWidth = indent; indent(pw, indent); while (tokenizer.hasMoreTokens()) { String next = tokenizer.nextToken(); pw.print(next); pw.print(" "); curWidth += next.length() + 1; if (curWidth > width) { pw.println(); indent(pw, indent); curWidth = 0; } } pw.println(); } private static void indent(PrintWriter pw, int indent) { for (int i = 0; i < indent; i++) { pw.print(" "); } } public static Collection rewrap(String lines) { Collection result = new ArrayList<>(); String[] words = lines.split("[ \n]"); String line = ""; int cols = 0; for (String w : words) { cols += w.length(); line += w + " "; if (cols > 40) { result.add(line); line = ""; cols = 0; } } if (!line.trim().isEmpty()) { result.add(line); } return result; } static class BurningTask implements Runnable { @Override public void run() { while (!Thread.interrupted()); // burn; } } public static void check(Class klass, String... fieldNames) { for (String fieldName : fieldNames) { check(klass, fieldName); } } public static void check(Class klass, String fieldName) { final long requiredGap = 128; long markerBegin = getOffset(klass, "markerBegin"); long markerEnd = getOffset(klass, "markerEnd"); long off = getOffset(klass, fieldName); if (markerEnd - off < requiredGap || off - markerBegin < requiredGap) { throw new IllegalStateException("Consistency check failed for " + fieldName + ", off = " + off + ", markerBegin = " + markerBegin + ", markerEnd = " + markerEnd); } } public static long getOffset(Class klass, String fieldName) { do { try { Field f = klass.getDeclaredField(fieldName); return U.objectFieldOffset(f); } catch (NoSuchFieldException e) { // whatever, will try superclass } klass = klass.getSuperclass(); } while (klass != null); throw new IllegalStateException("Can't find field \"" + fieldName + "\""); } public static boolean isWindows() { return System.getProperty("os.name").contains("indows"); } public static String getCurrentJvm() { return System.getProperty("java.home") + File.separator + "bin" + File.separator + "java" + (isWindows() ? ".exe" : ""); } public static String getCurrentJvmVersion() { return "JDK " + System.getProperty("java.version") + ", VM " + System.getProperty("java.vm.version"); } public static String getCurrentOSVersion() { return System.getProperty("os.name") + ", " + System.getProperty("os.arch") + ", " + System.getProperty("os.version"); } /** * Gets PID of the current JVM. * * @return PID. */ public static long getPid() { final String DELIM = "@"; String name = ManagementFactory.getRuntimeMXBean().getName(); if (name != null) { int idx = name.indexOf(DELIM); if (idx != -1) { String str = name.substring(0, name.indexOf(DELIM)); try { return Long.parseLong(str); } catch (NumberFormatException nfe) { throw new IllegalStateException("Process PID is not a number: " + str); } } } throw new IllegalStateException("Unsupported PID format: " + name); } /** * Gets the PID of the target process. * @param process to poll * @return PID, or zero if no PID is found */ public static long getPid(Process process) { // Step 1. Try Process.pid, available since Java 9. try { Method m = Process.class.getMethod("pid"); Object pid = m.invoke(process); if (pid instanceof Long) { return (long) pid; } } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { // Fallthrough } // Step 2. Try to hack into the JDK 8- UNIXProcess. try { Class c = Class.forName("java.lang.UNIXProcess"); Field f = c.getDeclaredField("pid"); setAccessible(process, f); Object o = f.get(process); if (o instanceof Integer) { return (int) o; } } catch (NoSuchFieldException | ClassNotFoundException | IllegalAccessException e) { // Fallthrough } // Step 3. Try to hack into JDK 9+ ProcessImpl. // Renamed from UNIXProcess with JDK-8071481. try { Class c = Class.forName("java.lang.ProcessImpl"); Field f = c.getDeclaredField("pid"); setAccessible(process, f); Object o = f.get(process); if (o instanceof Integer) { return (int) o; } } catch (NoSuchFieldException | ClassNotFoundException | IllegalAccessException e) { // Fallthrough } // No dice, return zero return 0; } public static Collection tryWith(String... cmd) { Collection messages = new ArrayList<>(); try { Process p = new ProcessBuilder(cmd).start(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); // drain streams, else we might lock up InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), baos); InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), baos); errDrainer.start(); outDrainer.start(); int err = p.waitFor(); errDrainer.join(); outDrainer.join(); if (err != 0) { messages.add(baos.toString()); } } catch (IOException ex) { return Collections.singleton(ex.getMessage()); } catch (InterruptedException ex) { throw new IllegalStateException(ex); } return messages; } public static Process runAsync(String... cmd) { try { return new ProcessBuilder(cmd).start(); } catch (IOException ex) { throw new IllegalStateException(ex); } } public static Collection runWith(String... cmds) { return runWith(Arrays.asList(cmds)); } public static Collection runWith(List cmd) { Collection messages = new ArrayList<>(); try { Process p = new ProcessBuilder(cmd).start(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); // drain streams, else we might lock up InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), baos); InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), baos); errDrainer.start(); outDrainer.start(); int err = p.waitFor(); errDrainer.join(); outDrainer.join(); messages.add(baos.toString()); } catch (IOException ex) { return Collections.singleton(ex.getMessage()); } catch (InterruptedException ex) { throw new IllegalStateException(ex); } return messages; } /** * We don't access the complete system properties via {@link System#getProperties()} because * this would require read/write permissions to the properties. Just copy the properties we * want to record in the result. * * @return Copy of system properties we want to record in the results. */ public static Properties getRecordedSystemProperties() { String[] names = new String[]{"java.version", "java.vm.version", "java.vm.name"}; Properties p = new Properties(); for (String i : names) { p.setProperty(i, System.getProperty(i)); } return p; } public static Properties readPropertiesFromCommand(List cmd) { Properties out = new Properties(); try { File tempFile = FileUtils.tempFile("properties"); List cmdWithFile = new ArrayList<>(cmd); cmdWithFile.add(tempFile.getAbsolutePath()); Collection errs = tryWith(cmdWithFile.toArray(new String[0])); if (!errs.isEmpty()) { throw new RuntimeException("Unable to extract forked JVM properties using: '" + join(cmd, " ") + "'; " + errs); } try (InputStream in = new BufferedInputStream(new FileInputStream(tempFile))) { // This will automatically pick UTF-8 based on the encoding in the XML declaration. out.loadFromXML(in); } } catch (IOException ex) { throw new RuntimeException(ex); } return out; } /** * Adapts Iterator for Iterable. * Can be iterated only once! * * @param element type * @param it iterator * @return iterable for given iterator */ public static Iterable adaptForLoop(final Iterator it) { return () -> it; } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java000066400000000000000000000077431446271450100246450ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.StringWriter; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Properties; import java.util.concurrent.TimeUnit; public class Version { private static final int UPDATE_INTERVAL = 180; /** * @return the version, build date and update hint. */ public static String getVersion() { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); printVersion(pw); pw.close(); return sw.toString(); } /** * @return only version, e.g. "1.19", or "-" if the version cannot be determined. */ public static String getPlainVersion() { Properties p = new Properties(); InputStream s = Version.class.getResourceAsStream("/jmh.properties"); if (s == null) { return "-"; } try { p.load(s); } catch (IOException e) { return "-"; } finally { FileUtils.safelyClose(s); } String version = (String) p.get("jmh.version"); if (version == null) { return "-"; } return version; } private static void printVersion(PrintWriter pw) { Properties p = new Properties(); InputStream s = Version.class.getResourceAsStream("/jmh.properties"); if (s == null) { pw.print("Cannot figure out JMH version, no jmh.properties"); return; } try { p.load(s); } catch (IOException e) { pw.print("Cannot figure out JMH version"); return; } finally { FileUtils.safelyClose(s); } String version = (String) p.get("jmh.version"); if (version == null) { pw.print("Cannot read jmh.version"); return; } pw.print("JMH " + version + " "); String time = (String) p.get("jmh.buildDate"); if (time == null) { pw.print("(cannot read jmh.buildDate)"); return; } pw.print("(released "); try { Date parse = new SimpleDateFormat("yyyy/MM/dd", Locale.ROOT).parse(time); long diff = (System.currentTimeMillis() - parse.getTime()) / TimeUnit.DAYS.toMillis(1); if (diff > 0) { pw.print(String.format("%d days ago", diff)); if (diff > UPDATE_INTERVAL) { pw.print(", please consider updating!"); } } else { pw.print("today"); } } catch (ParseException e) { pw.print(time); } pw.print(")"); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/lines/000077500000000000000000000000001446271450100234545ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/lines/Armor.java000066400000000000000000000121721446271450100254020ustar00rootroot00000000000000/* * Copyright (c) 2020, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util.lines; /** * This implements a simple String armoring scheme that resembles Base64. * We cannot use Base64 implementations from JDK yet, because the lowest language level is at 7. */ class Armor { // 64 characters, plus a padding symbol at the end. static final String DICT = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; private static void encodeStep(int[] ibuf, int[] obuf) { obuf[0] = ((ibuf[0] & 0x3F) ); obuf[1] = ((ibuf[0] & 0xFF) >> 6) + ((ibuf[1] & 0xF) << 2); obuf[2] = ((ibuf[1] & 0xFF) >> 4) + ((ibuf[2] & 0x3) << 4); obuf[3] = ((ibuf[2] & 0xFF) >> 2); obuf[4] = ((ibuf[3] & 0x3F) ); obuf[5] = ((ibuf[3] & 0xFF) >> 6) + ((ibuf[4] & 0xF) << 2); obuf[6] = ((ibuf[4] & 0xFF) >> 4) + ((ibuf[5] & 0x3) << 4); obuf[7] = ((ibuf[5] & 0xFF) >> 2); } private static void decodeStep(int[] ibuf, int[] obuf) { obuf[0] = (((ibuf[0] & 0xFF) ) + ((ibuf[1] & 0x3) << 6)); obuf[1] = (((ibuf[1] & 0xFF) >> 2) + ((ibuf[2] & 0xF) << 4)); obuf[2] = (((ibuf[2] & 0xFF) >> 4) + ((ibuf[3] & 0x3F) << 2)); obuf[3] = (((ibuf[4] & 0xFF) ) + ((ibuf[5] & 0x3) << 6)); obuf[4] = (((ibuf[5] & 0xFF) >> 2) + ((ibuf[6] & 0xF) << 4)); obuf[5] = (((ibuf[6] & 0xFF) >> 4) + ((ibuf[7] & 0x3F) << 2)); } public static String encode(String src) { StringBuilder sb = new StringBuilder(); char[] chars = src.toCharArray(); int[] ibuf = new int[6]; int[] obuf = new int[8]; for (int c = 0; c < chars.length / 3; c++) { for (int i = 0; i < 3; i++) { ibuf[i*2 + 0] = chars[c*3 + i] & 0xFF; ibuf[i*2 + 1] = (chars[c*3 + i] >> 8) & 0xFF; } encodeStep(ibuf, obuf); for (int i = 0; i < 8; i++) { sb.append(DICT.charAt(obuf[i])); } } int tail = chars.length % 3; if (tail != 0) { int tailStart = chars.length / 3 * 3; char PAD = DICT.charAt(DICT.length() - 1); for (int i = 0; i < tail; i++) { ibuf[i*2 + 0] = chars[tailStart + i] & 0xFF; ibuf[i*2 + 1] = (chars[tailStart + i] >> 8) & 0xFF; } for (int i = tail; i < 3; i++) { ibuf[i*2 + 0] = 0; ibuf[i*2 + 1] = 0; } encodeStep(ibuf, obuf); for (int i = 0; i < tail*3; i++) { sb.append(DICT.charAt(obuf[i])); } for (int i = tail*3; i < 8; i++) { sb.append(PAD); } } return sb.toString(); } public static String decode(String encoded) { char[] encChars = encoded.toCharArray(); char[] decChars = new char[encChars.length / 8 * 3]; if (encChars.length % 8 != 0) { throw new IllegalArgumentException("The length should be multiple of 8"); } final int PAD_IDX = DICT.length() - 1; int[] ibuf = new int[8]; int[] obuf = new int[6]; int oLen = 0; int cut = 0; for (int c = 0; c < encChars.length/8; c++) { for (int i = 0; i < 8; i++) { ibuf[i] = DICT.indexOf(encChars[c*8 + i]); } if (ibuf[3] == PAD_IDX) { for (int i = 3; i < 8; i++) { ibuf[i] = 0; } cut = 2; } else if (ibuf[6] == PAD_IDX) { for (int i = 6; i < 8; i++) { ibuf[i] = 0; } cut = 1; } decodeStep(ibuf, obuf); decChars[oLen++] = (char)(obuf[0] + (obuf[1] << 8)); decChars[oLen++] = (char)(obuf[2] + (obuf[3] << 8)); decChars[oLen++] = (char)(obuf[4] + (obuf[5] << 8)); } return new String(decChars, 0, decChars.length - cut); } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/lines/Constants.java000066400000000000000000000034061446271450100262760ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util.lines; public class Constants { public static final String MAGIC = "JMH "; public static final char TAG_EMPTY_OPTIONAL = 'E'; public static final char TAG_STRING = 'S'; public static final char TAG_INT = 'I'; public static final char TAG_TIMEVALUE = 'T'; public static final char TAG_STRING_COLLECTION = 'L'; public static final char TAG_INT_ARRAY = 'A'; public static final char TAG_PARAM_MAP = 'M'; public static final char TAG_TIMEUNIT = 'U'; } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java000066400000000000000000000140461446271450100271760ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util.lines; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Optional; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import static org.openjdk.jmh.util.lines.Constants.*; public class TestLineReader { private final String line; private final boolean correct; private int cursor; public TestLineReader(String line) { this.line = line; this.correct = (line.length() > MAGIC.length() && line.startsWith(MAGIC)); this.cursor = MAGIC.length(); } private int readLen() { StringBuilder sb = new StringBuilder(); char c = line.charAt(cursor); while (Character.isDigit(c)) { sb.append(c); cursor++; c = line.charAt(cursor); } cursor++; return Integer.parseInt(sb.toString()); } private String readString() { int len = readLen(); String s = line.substring(cursor, cursor + len); cursor += len + 1; return s; } private String readArmoredString() { return Armor.decode(readString()); } private char readChar() { char c = line.charAt(cursor); cursor += 2; return c; } public String nextString() { char tag = readChar(); if (tag == TAG_STRING) { return readString(); } else { throw error("unexpected tag = " + tag); } } private RuntimeException error(String msg) { return new IllegalStateException("Error: " + msg + "\n at \"" + line + "\", pos " + cursor); } public boolean isCorrect() { return correct; } public Optional nextOptionalInt() { char tag = readChar(); if (tag == Constants.TAG_EMPTY_OPTIONAL) { return Optional.none(); } else if (tag == TAG_INT) { return Optional.of(Integer.valueOf(readString())); } else { throw error("unexpected tag = " + tag); } } public Optional nextOptionalString() { char tag = readChar(); if (tag == Constants.TAG_EMPTY_OPTIONAL) { return Optional.none(); } else if (tag == TAG_STRING) { return Optional.of(readString()); } else { throw error("unexpected tag = " + tag); } } public Optional nextOptionalTimeValue() { char tag = readChar(); if (tag == Constants.TAG_EMPTY_OPTIONAL) { return Optional.none(); } else if (tag == TAG_TIMEVALUE) { return Optional.of(TimeValue.fromString(readString())); } else { throw error("unexpected tag = " + tag); } } public Optional nextOptionalTimeUnit() { char tag = readChar(); if (tag == Constants.TAG_EMPTY_OPTIONAL) { return Optional.none(); } else if (tag == TAG_TIMEUNIT) { return Optional.of(TimeUnit.valueOf(readString())); } else { throw error("unexpected tag = " + tag); } } public Optional> nextOptionalStringCollection() { char tag = readChar(); if (tag == Constants.TAG_EMPTY_OPTIONAL) { return Optional.none(); } else if (tag == TAG_STRING_COLLECTION) { int len = readLen(); Collection list = new ArrayList<>(); for (int c = 0; c < len; c++) { list.add(readString()); } return Optional.of(list); } else { throw error("unexpected tag = " + tag); } } public int[] nextIntArray() { char tag = readChar(); if (tag == TAG_INT_ARRAY) { int len = readLen(); int[] rs = new int[len]; for (int c = 0; c < len; c++) { rs[c] = Integer.parseInt(readString()); } return rs; } else { throw error("unexpected tag = " + tag); } } public Optional> nextOptionalParamCollection() { char tag = readChar(); if (tag == Constants.TAG_EMPTY_OPTIONAL) { return Optional.none(); } else if (tag == TAG_PARAM_MAP) { Map result = new HashMap<>(); int kvs = readLen(); for (int kv = 0; kv < kvs; kv++) { String key = readString(); int vlen = readLen(); String[] values = new String[vlen]; for (int v = 0; v < vlen; v++) { values[v] = readArmoredString(); } result.put(key, values); } return Optional.of(result); } else { throw error("unexpected tag = " + tag); } } } jmh-1.37/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineWriter.java000066400000000000000000000107201446271450100272430ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util.lines; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Optional; import java.util.Collection; import java.util.Map; import java.util.concurrent.TimeUnit; import static org.openjdk.jmh.util.lines.Constants.*; public class TestLineWriter { private final StringBuilder line; public TestLineWriter() { line = new StringBuilder(); line.append(MAGIC); } private void appendWithLen(String s) { appendLen(s.length()); line.append(s); line.append(" "); } private void appendArmoredWithLen(String s) { String as = Armor.encode(s); appendLen(as.length()); line.append(as); line.append(" "); } private void appendLen(int len) { line.append(len); line.append(" "); } private void appendTag(char tag) { line.append(tag); line.append(" "); } public void putString(String s) { appendTag(TAG_STRING); appendWithLen(s); } public void putOptionalInt(Optional opt) { if (!opt.hasValue()) { appendTag(TAG_EMPTY_OPTIONAL); } else { appendTag(TAG_INT); appendWithLen(String.valueOf(opt.get())); } } public void putOptionalString(Optional opt) { if (!opt.hasValue()) { appendTag(TAG_EMPTY_OPTIONAL); } else { appendTag(TAG_STRING); appendWithLen(opt.get()); } } public void putIntArray(int[] arr) { appendTag(TAG_INT_ARRAY); appendLen(arr.length); for (int v : arr) { appendWithLen(String.valueOf(v)); } } public void putOptionalStringCollection(Optional> opt) { if (!opt.hasValue()) { appendTag(TAG_EMPTY_OPTIONAL); } else { appendTag(TAG_STRING_COLLECTION); Collection coll = opt.get(); appendLen(coll.size()); for (String s : coll) { appendWithLen(s); } } } public void putOptionalTimeValue(Optional opt) { if (!opt.hasValue()) { appendTag(TAG_EMPTY_OPTIONAL); } else { appendTag(TAG_TIMEVALUE); appendWithLen(opt.get().toString()); } } public void putOptionalTimeUnit(Optional opt) { if (!opt.hasValue()) { appendTag(TAG_EMPTY_OPTIONAL); } else { appendTag(TAG_TIMEUNIT); appendWithLen(opt.get().toString()); } } public void putOptionalParamCollection(Optional> opt) { if (!opt.hasValue()) { appendTag(TAG_EMPTY_OPTIONAL); } else { appendTag(TAG_PARAM_MAP); Map map = opt.get(); appendLen(map.size()); for (String key : map.keySet()) { appendWithLen(key); String[] vals = map.get(key); appendLen(vals.length); for (String value : vals) { appendArmoredWithLen(value); } } } } @Override public String toString() { return line.toString(); } } jmh-1.37/jmh-core/src/main/resources/000077500000000000000000000000001446271450100174575ustar00rootroot00000000000000jmh-1.37/jmh-core/src/main/resources/LICENSE000066400000000000000000000455121446271450100204730ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-core/src/main/resources/THIRD-PARTY000066400000000000000000000350611446271450100211560ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-core/src/main/resources/checkstyle.xml000066400000000000000000000173111446271450100223420ustar00rootroot00000000000000 jmh-1.37/jmh-core/src/main/resources/findbugs.xml000066400000000000000000000632411446271450100220100ustar00rootroot00000000000000 jmh-1.37/jmh-core/src/main/resources/jmh-security-minimal-runner.policy000066400000000000000000000013621446271450100262600ustar00rootroot00000000000000grant { permission java.lang.RuntimePermission "accessDeclaredMembers"; permission java.lang.RuntimePermission "modifyThread"; permission java.lang.RuntimePermission "accessClassInPackage.sun.misc"; permission java.lang.RuntimePermission "setSecurityManager"; permission java.lang.RuntimePermission "shutdownHooks"; permission java.lang.RuntimePermission "setIO"; permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; permission java.util.PropertyPermission "*", "read"; permission java.lang.management.ManagementPermission "monitor"; permission java.io.FilePermission "<>", "read,write,execute,delete"; permission java.net.SocketPermission "*", "connect,resolve,accept,listen"; }; jmh-1.37/jmh-core/src/main/resources/jmh-security-minimal.policy000066400000000000000000000002071446271450100247460ustar00rootroot00000000000000grant { permission java.lang.RuntimePermission "modifyThread"; permission java.lang.RuntimePermission "setSecurityManager"; }; jmh-1.37/jmh-core/src/main/resources/jmh-security.policy000066400000000000000000000000671446271450100233260ustar00rootroot00000000000000grant { permission java.security.AllPermission; }; jmh-1.37/jmh-core/src/main/resources/jmh.properties000066400000000000000000000023371446271450100223600ustar00rootroot00000000000000# # Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. # jmh.version=${project.version} jmh.buildDate=${buildDate} jmh-1.37/jmh-core/src/test/000077500000000000000000000000001446271450100155005ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/000077500000000000000000000000001446271450100164215ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/000077500000000000000000000000001446271450100172105ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/000077500000000000000000000000001446271450100206425ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/000077500000000000000000000000001446271450100214205ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java000066400000000000000000000042301446271450100250060ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.infra.Blackhole; public class BlackholeTest { @Test public void test() { int tlr = 1; int tlrMask = 2; for (int t = 0; t < 1_000_000_000; t++) { tlr = (tlr * 48271); if ((tlr & tlrMask) == 0) { // SHOULD ALMOST NEVER HAPPEN IN MEASUREMENT tlrMask = (tlrMask << 1) + 2; System.out.println(t); } } } @Test public void testUserConstructor() { try { new Blackhole("Boyaa"); Assert.fail("Should have failed"); } catch (IllegalStateException e) { // expected } try { new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous."); } catch (Throwable e) { Assert.fail("Failed unexpectedly"); } } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/generators/000077500000000000000000000000001446271450100235715ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/generators/core/000077500000000000000000000000001446271450100245215ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorTest.java000066400000000000000000000042251446271450100317700ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.core; import org.junit.Assert; import org.junit.Test; import java.util.concurrent.ThreadLocalRandom; public class BenchmarkGeneratorTest { static final int TAB_SIZE = 4; @Test public void testIndentsForward() { for (int c = 0; c < 10; c++) { BenchmarkGenerator.INDENTS = null; Assert.assertEquals(c*TAB_SIZE, BenchmarkGenerator.ident(c).length()); } } @Test public void testIndentsBackwards() { for (int c = 10; c >= 0; c--) { BenchmarkGenerator.INDENTS = null; Assert.assertEquals(c*TAB_SIZE, BenchmarkGenerator.ident(c).length()); } } @Test public void testIndentsRandom() { for (int c = 0; c < 10; c++) { BenchmarkGenerator.INDENTS = null; int i = ThreadLocalRandom.current().nextInt(10); Assert.assertEquals(i*TAB_SIZE, BenchmarkGenerator.ident(i).length()); } } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/profile/000077500000000000000000000000001446271450100230605ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfAsmAddressTest.java000066400000000000000000000131041446271450100274250ustar00rootroot00000000000000/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.junit.Assert; import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; public class PerfAsmAddressTest { static final HashMap> TESTS = new HashMap<>(); static long addr(String s) { return Long.parseLong(s, 16); } static { TESTS.put("0x00007f815c65724e: test %eax,(%r8)", Arrays.asList(addr("7f815c65724e"))); TESTS.put("0x00007f815c657239: je 0x00007f815c657290", Arrays.asList(addr("7f815c657239"), addr("7f815c657290"))); TESTS.put("0x00007f815c657256: movabs $0x7f8171798570,%r10", Arrays.asList(addr("7f815c657256"), addr("7f8171798570"))); TESTS.put("0x0000ffff685c7d2c: b 0x0000ffff685c7cf0", Arrays.asList(addr("ffff685c7d2c"), addr("ffff685c7cf0"))); TESTS.put("0x0000ffff685c7d1c: b.ne 0x0000ffff685c7cb4 // b.any", Arrays.asList(addr("ffff685c7d1c"), addr("ffff685c7cb4"))); TESTS.put("0x0000ffff685c7d1c: b.ne 0x0000ffff685c7cb4// b.any", Arrays.asList(addr("ffff685c7d1c"), addr("ffff685c7cb4"))); TESTS.put("0x0000ffff685c7d1c: b.ne 0x0000ffff685c7cb4;comment", Arrays.asList(addr("ffff685c7d1c"), addr("ffff685c7cb4"))); TESTS.put("0x0000ffff685c7d1c:b.ne 0x0000ffff685c7cb4", Arrays.asList(addr("ffff685c7d1c"), addr("ffff685c7cb4"))); TESTS.put("0x0000ffff685c7d1c: b.ne\t0x0000ffff685c7cb4", Arrays.asList(addr("ffff685c7d1c"), addr("ffff685c7cb4"))); } @Test public void testNoPrefix() { List empty = new ArrayList<>(); for (String line : TESTS.keySet()) { List expected = TESTS.get(line); String leadingSpace = " " + line; String trailingSpace = line + " "; Assert.assertEquals(line, expected, AbstractPerfAsmProfiler.parseAddresses(line, false, true)); Assert.assertEquals(line, expected, AbstractPerfAsmProfiler.parseAddresses(leadingSpace, false, true)); Assert.assertEquals(line, empty, AbstractPerfAsmProfiler.parseAddresses(leadingSpace, true, true)); Assert.assertEquals(line, expected, AbstractPerfAsmProfiler.parseAddresses(trailingSpace, false, true)); Assert.assertEquals(line, expected, AbstractPerfAsmProfiler.parseAddresses(trailingSpace, true, true)); } } @Test public void testPrefix() { List empty = new ArrayList<>(); for (String line : TESTS.keySet()) { List expected = TESTS.get(line); String prefixedLine = "something " + line; String prefixedLeadingLine = " something " + line; String prefixedTrailingLine = "something " + line + " "; Assert.assertEquals(line, empty, AbstractPerfAsmProfiler.parseAddresses(prefixedLine, false, true)); Assert.assertEquals(line, empty, AbstractPerfAsmProfiler.parseAddresses(prefixedLeadingLine, false, true)); Assert.assertEquals(line, empty, AbstractPerfAsmProfiler.parseAddresses(prefixedTrailingLine, false, true)); Assert.assertEquals(line, empty, AbstractPerfAsmProfiler.parseAddresses(prefixedLine, true, true)); Assert.assertEquals(line, empty, AbstractPerfAsmProfiler.parseAddresses(prefixedLeadingLine, true, true)); Assert.assertEquals(line, empty, AbstractPerfAsmProfiler.parseAddresses(prefixedTrailingLine, true, true)); Assert.assertEquals(line, expected, AbstractPerfAsmProfiler.parseAddresses(prefixedLine, false, false)); Assert.assertEquals(line, expected, AbstractPerfAsmProfiler.parseAddresses(prefixedLeadingLine, false, false)); Assert.assertEquals(line, expected, AbstractPerfAsmProfiler.parseAddresses(prefixedTrailingLine, false, false)); Assert.assertEquals(line, expected, AbstractPerfAsmProfiler.parseAddresses(prefixedLine, true, false)); Assert.assertEquals(line, expected, AbstractPerfAsmProfiler.parseAddresses(prefixedLeadingLine, true, false)); Assert.assertEquals(line, expected, AbstractPerfAsmProfiler.parseAddresses(prefixedTrailingLine, true, false)); } } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java000066400000000000000000000115211446271450100264520ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.junit.Assert; import org.junit.Test; import java.util.ArrayList; import java.util.List; public class PerfParseTest { private static final double ASSERT_ACCURACY = 0.0000001; @Test public void parsePerf_4_4() { String[] lines = new String[] { "328650.667569: instructions: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", "328650.667569: instructions: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/with spaces/libjvm.so)" }; for (String line : lines) { LinuxPerfAsmProfiler.PerfLine perfLine = LinuxPerfAsmProfiler.parsePerfLine(line); Assert.assertEquals(328650.667569D, perfLine.time(), ASSERT_ACCURACY); Assert.assertEquals("instructions", perfLine.eventName()); Assert.assertEquals(0x7f82b6a8beb4L, perfLine.addr()); Assert.assertEquals("ConstantPoolCache::allocate", perfLine.symbol()); Assert.assertEquals("libjvm.so", perfLine.lib()); } } @Test public void parseRaggedSymbols() { String[] lines = new String[] { "328650.667569: instructions: 7f82b6a8beb4 ConstantPoolCache::allocate(Thread* thr) (/somewhere/on/my/filesystem/libjvm.so)", }; for (String line : lines) { LinuxPerfAsmProfiler.PerfLine perfLine = LinuxPerfAsmProfiler.parsePerfLine(line); Assert.assertEquals(328650.667569D, perfLine.time(), ASSERT_ACCURACY); Assert.assertEquals("instructions", perfLine.eventName()); Assert.assertEquals(0x7f82b6a8beb4L, perfLine.addr()); Assert.assertEquals("ConstantPoolCache::allocate(Thread* thr)", perfLine.symbol()); Assert.assertEquals("libjvm.so", perfLine.lib()); } } @Test public void parseOptionalTag() { String[] lines = new String[] { "328650.667569: instructions:u: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", "328650.667569: instructions:uk: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", "328650.667569: instructions:k: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", "328650.667569: instructions:HG: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", "328650.667569: instructions:H: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", "328650.667569: instructions:: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)" }; for (String line : lines) { LinuxPerfAsmProfiler.PerfLine perfLine = LinuxPerfAsmProfiler.parsePerfLine(line); Assert.assertEquals(328650.667569D, perfLine.time(), ASSERT_ACCURACY); Assert.assertEquals("instructions", perfLine.eventName()); Assert.assertEquals(0x7f82b6a8beb4L, perfLine.addr()); Assert.assertEquals("ConstantPoolCache::allocate", perfLine.symbol()); Assert.assertEquals("libjvm.so", perfLine.lib()); } } @Test public void stripEvents() { List list = new ArrayList<>(); list.add("cycles"); list.add("instructions:u:"); list.add("branches:pppu:"); List stripped = LinuxPerfAsmProfiler.stripPerfEventNames(list); Assert.assertEquals("cycles", stripped.get(0)); Assert.assertEquals("instructions", stripped.get(1)); Assert.assertEquals("branches", stripped.get(2)); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java000066400000000000000000000111221446271450100303760ustar00rootroot00000000000000/* * Copyright (c) 2016, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.profile; import org.junit.Assert; import org.junit.Test; public class SafepointsProfilerTest { @Test public void parseJDK7u77_Point() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( "1.095: Total time for which application threads were stopped: 0.0014010 seconds"); Assert.assertNotNull(data); Assert.assertEquals(1_095_000_000L, data.timestamp); Assert.assertEquals( 1_401_000L, data.stopTime); Assert.assertEquals(Long.MIN_VALUE, data.ttspTime); } @Test public void parseJDK7u77_Comma() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( "1,095: Total time for which application threads were stopped: 0,0014010 seconds"); Assert.assertNotNull(data); Assert.assertEquals(1_095_000_000L, data.timestamp); Assert.assertEquals( 1_401_000L, data.stopTime); Assert.assertEquals(Long.MIN_VALUE, data.ttspTime); } @Test public void parseJDK8u101_Dot() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( "5.042: Total time for which application threads were stopped: 0.0028944 seconds, Stopping threads took: 0.0028351 seconds"); Assert.assertNotNull(data); Assert.assertEquals(5_042_000_000L, data.timestamp); Assert.assertEquals( 2_894_400L, data.stopTime); Assert.assertEquals( 2_835_100L, data.ttspTime); } @Test public void parseJDK8u101_Comma() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( "5,042: Total time for which application threads were stopped: 0,0028944 seconds, Stopping threads took: 0,0028351 seconds"); Assert.assertNotNull(data); Assert.assertEquals(5_042_000_000L, data.timestamp); Assert.assertEquals( 2_894_400L, data.stopTime); Assert.assertEquals( 2_835_100L, data.ttspTime); } @Test public void parseJDK9b140_Dot() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( "[71.633s][info][safepoint] Total time for which application threads were stopped: 0.0359611 seconds, Stopping threads took: 0.0000516 seconds"); Assert.assertNotNull(data); Assert.assertEquals(71_633_000_000L, data.timestamp); Assert.assertEquals( 35_961_100L, data.stopTime); Assert.assertEquals( 51_600L, data.ttspTime); } @Test public void parseJDK9b140_Comma() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( "[71,633s][info][safepoint] Total time for which application threads were stopped: 0,0359611 seconds, Stopping threads took: 0,0000516 seconds"); Assert.assertNotNull(data); Assert.assertEquals(71_633_000_000L, data.timestamp); Assert.assertEquals( 35_961_100L, data.stopTime); Assert.assertEquals( 51_600L, data.ttspTime); } @Test public void parseJDK9b140_Whitespace() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( "[71,633s][info][safepoint ] Total time for which application threads were stopped: 0,0359611 seconds, Stopping threads took: 0.0000516 seconds"); Assert.assertNotNull(data); Assert.assertEquals(71_633_000_000L, data.timestamp); Assert.assertEquals( 35_961_100L, data.stopTime); Assert.assertEquals( 51_600L, data.ttspTime); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/000077500000000000000000000000001446271450100231215ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/ResultAggregationTest.java000066400000000000000000000270051446271450100302560ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.util.SampleBuffer; import java.util.Arrays; import java.util.concurrent.TimeUnit; public class ResultAggregationTest { private static final double ASSERT_ACCURACY = 0.0000001; @Test public void testThroughput() { IterationResult ir = new IterationResult(null, null, null); ir.addResult(new ThroughputResult(ResultRole.PRIMARY, "", 10_000, 1, TimeUnit.NANOSECONDS)); ir.addResult(new ThroughputResult(ResultRole.PRIMARY, "", 10_000, 1, TimeUnit.NANOSECONDS)); ir.addResult(new ThroughputResult(ResultRole.SECONDARY, "sec", 5_000, 1, TimeUnit.NANOSECONDS)); ir.addResult(new ThroughputResult(ResultRole.SECONDARY, "sec", 5_000, 1, TimeUnit.NANOSECONDS)); Assert.assertEquals(20_000.0, ir.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(10_000.0, ir.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, ir.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); Assert.assertEquals(2, ir.getRawSecondaryResults().get("sec").size()); BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); br.addBenchmarkResult(new ThroughputResult(ResultRole.SECONDARY, "bench", 3_000, 1, TimeUnit.NANOSECONDS)); Assert.assertEquals(20_000.0, br.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(10_000.0, br.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); Assert.assertEquals(20_000.0, rr.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(10_000.0, rr.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(4, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, rr.getBenchmarkResults().size()); } @Test public void testAverageTime() { IterationResult ir = new IterationResult(null, null, null); ir.addResult(new AverageTimeResult(ResultRole.PRIMARY, "", 1, 10_000, TimeUnit.NANOSECONDS)); ir.addResult(new AverageTimeResult(ResultRole.PRIMARY, "", 1, 10_000, TimeUnit.NANOSECONDS)); ir.addResult(new AverageTimeResult(ResultRole.SECONDARY, "sec", 1, 5_000, TimeUnit.NANOSECONDS)); ir.addResult(new AverageTimeResult(ResultRole.SECONDARY, "sec", 1, 5_000, TimeUnit.NANOSECONDS)); Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, ir.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); Assert.assertEquals(2, ir.getRawSecondaryResults().get("sec").size()); BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); br.addBenchmarkResult(new AverageTimeResult(ResultRole.SECONDARY, "bench", 1, 3_000, TimeUnit.NANOSECONDS)); Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(4, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, rr.getBenchmarkResults().size()); } @Test public void testSampleTime() { SampleBuffer sb10000 = new SampleBuffer(); sb10000.add(10_000); SampleBuffer sb5000 = new SampleBuffer(); sb5000.add(5_000); SampleBuffer sb3000 = new SampleBuffer(); sb3000.add(3_000); IterationResult ir = new IterationResult(null, null, null); ir.addResult(new SampleTimeResult(ResultRole.PRIMARY, "", sb10000, TimeUnit.NANOSECONDS)); ir.addResult(new SampleTimeResult(ResultRole.PRIMARY, "", sb10000, TimeUnit.NANOSECONDS)); ir.addResult(new SampleTimeResult(ResultRole.SECONDARY, "sec", sb5000, TimeUnit.NANOSECONDS)); ir.addResult(new SampleTimeResult(ResultRole.SECONDARY, "sec", sb5000, TimeUnit.NANOSECONDS)); Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); Assert.assertEquals(2, ir.getRawSecondaryResults().get("sec").size()); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, ir.getSecondaryResults().get("sec").getSampleCount()); BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); br.addBenchmarkResult(new SampleTimeResult(ResultRole.SECONDARY, "bench", sb3000, TimeUnit.NANOSECONDS)); Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(4, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(8, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(8, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, rr.getBenchmarkResults().size()); } @Test public void testSingleShot() { IterationResult ir = new IterationResult(null, null, null); ir.addResult(new SingleShotResult(ResultRole.PRIMARY, "", 10_000, 1, TimeUnit.NANOSECONDS)); ir.addResult(new SingleShotResult(ResultRole.PRIMARY, "", 10_000, 1, TimeUnit.NANOSECONDS)); ir.addResult(new SingleShotResult(ResultRole.SECONDARY, "sec", 5_000, 1, TimeUnit.NANOSECONDS)); ir.addResult(new SingleShotResult(ResultRole.SECONDARY, "sec", 5_000, 1, TimeUnit.NANOSECONDS)); Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, ir.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); Assert.assertEquals(2, ir.getRawSecondaryResults().get("sec").size()); BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); br.addBenchmarkResult(new SingleShotResult(ResultRole.SECONDARY, "bench", 3_000, 1, TimeUnit.NANOSECONDS)); Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore(), ASSERT_ACCURACY); Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(4, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, rr.getBenchmarkResults().size()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java000066400000000000000000000064051446271450100277160ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.junit.BeforeClass; import org.junit.Test; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.runner.IterationType; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Utils; import org.openjdk.jmh.util.Version; import java.util.Collections; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; /** * Tests for AggregateResult */ public class TestAggregateResult { private static IterationResult result; private static final double[] values = {10.0, 20.0, 30.0, 40.0, 50.0}; @BeforeClass public static void setupClass() { result = new IterationResult( new BenchmarkParams("blah", "blah", false, 1, new int[]{1}, Collections.emptyList(), 1, 1, new IterationParams(IterationType.WARMUP, 1, TimeValue.seconds(1), 1), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Collections.emptyList(), System.getProperty("java.version"), System.getProperty("java.vm.name"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.days(1), 1), null ); for (double d : values) { result.addResult(new ThroughputResult(ResultRole.PRIMARY, "test1", (long) d, 10 * 1000 * 1000, TimeUnit.MILLISECONDS)); } } @Test public void testScore() { assertEquals(15.0, result.getPrimaryResult().getScore(), 0.00001); } @Test public void testScoreUnit() { assertEquals((new ThroughputResult(ResultRole.PRIMARY, "test1", 1, 1, TimeUnit.MILLISECONDS)).getScoreUnit(), result.getScoreUnit()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/TestAverageTimeResult.java000066400000000000000000000067261446271450100302270ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.junit.Test; import java.util.Arrays; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; public class TestAverageTimeResult { private static final double ASSERT_ACCURACY = 0.0000001; @Test public void testIterationAggregator1() { AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 2_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(1.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @Test public void testIterationAggregator2() { AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(1.0, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @Test public void testThreadAggregator1() { AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(1.0, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @Test public void testThreadAggregator2() { AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 2_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(1.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/TestBenchmarkResult.java000066400000000000000000000102461446271450100277200ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.util.ListStatistics; import java.util.Arrays; import java.util.Collection; import java.util.Map; public class TestBenchmarkResult { @Test public void testMissingSecondaries() { IterationResult ir1 = new IterationResult(null, null, null); ir1.addResult(new PrimaryResult()); ir1.addResult(new SecondaryResult("label1", 1)); IterationResult ir2 = new IterationResult(null, null, null); ir2.addResult(new PrimaryResult()); ir2.addResult(new SecondaryResult("label2", 2)); IterationResult ir3 = new IterationResult(null, null, null); ir3.addResult(new PrimaryResult()); ir3.addResult(new SecondaryResult("label2", 3)); BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir1, ir2, ir3)); Map sr = br.getSecondaryResults(); Assert.assertEquals(2, sr.size()); Assert.assertEquals(1.0D, sr.get("label1").getScore(), 0.001); Assert.assertEquals(5.0D, sr.get("label2").getScore(), 0.001); } public static class PrimaryResult extends Result { public PrimaryResult() { super(ResultRole.PRIMARY, "Boo", of(1.0D), "unit", AggregationPolicy.SUM); } @Override protected Aggregator getThreadAggregator() { return new PrimaryResultAggregator(); } @Override protected Aggregator getIterationAggregator() { return new PrimaryResultAggregator(); } } public static class SecondaryResult extends Result { public SecondaryResult(String label, double val) { super(ResultRole.SECONDARY, label, of(val), "unit", AggregationPolicy.SUM); } protected Aggregator getThreadAggregator() { return new SecondaryResultAggregator(); } @Override protected Aggregator getIterationAggregator() { return new SecondaryResultAggregator(); } } public static class PrimaryResultAggregator implements Aggregator { @Override public PrimaryResult aggregate(Collection results) { return new PrimaryResult(); } } public static class SecondaryResultAggregator implements Aggregator { @Override public SecondaryResult aggregate(Collection results) { String label = null; ListStatistics s = new ListStatistics(); for (SecondaryResult r : results) { if (label == null) { label = r.getLabel(); } else { Assert.assertEquals(label, r.getLabel()); } s.addValue(r.getScore()); } return new SecondaryResult(label, s.getSum()); } } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/TestSampleTimeResult.java000066400000000000000000000054361446271450100300730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.junit.Test; import org.openjdk.jmh.util.SampleBuffer; import java.util.Arrays; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; public class TestSampleTimeResult { private static final double ASSERT_ACCURACY = 0.0000001; @Test public void testIterationAggregator1() { SampleBuffer b1 = new SampleBuffer(); b1.add(1000); b1.add(2000); SampleBuffer b2 = new SampleBuffer(); b2.add(3000); b2.add(4000); SampleTimeResult r1 = new SampleTimeResult(ResultRole.PRIMARY, "Test1", b1, TimeUnit.MICROSECONDS); SampleTimeResult r2 = new SampleTimeResult(ResultRole.PRIMARY, "Test1", b2, TimeUnit.MICROSECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(2.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @Test public void testThreadAggregator1() { SampleBuffer b1 = new SampleBuffer(); b1.add(1000); b1.add(2000); SampleBuffer b2 = new SampleBuffer(); b2.add(3000); b2.add(4000); SampleTimeResult r1 = new SampleTimeResult(ResultRole.PRIMARY, "Test1", b1, TimeUnit.MICROSECONDS); SampleTimeResult r2 = new SampleTimeResult(ResultRole.PRIMARY, "Test1", b2, TimeUnit.MICROSECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(2.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/TestSingleShotResult.java000066400000000000000000000054531446271450100301110ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.junit.Test; import java.util.Arrays; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; public class TestSingleShotResult { private static final double ASSERT_ACCURACY = 0.0000001; @Test public void testIterationAggregator1() { SingleShotResult r1 = new SingleShotResult(ResultRole.PRIMARY, "Test1", 1000L, 1, TimeUnit.MICROSECONDS); SingleShotResult r2 = new SingleShotResult(ResultRole.PRIMARY, "Test1", 2000L, 1, TimeUnit.MICROSECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(1.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @Test public void testThreadAggregator1() { SingleShotResult r1 = new SingleShotResult(ResultRole.PRIMARY, "Test1", 1000L, 1, TimeUnit.MICROSECONDS); SingleShotResult r2 = new SingleShotResult(ResultRole.PRIMARY, "Test1", 2000L, 1, TimeUnit.MICROSECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(1.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @Test public void testMultiops() { SingleShotResult r1 = new SingleShotResult(ResultRole.PRIMARY, "Test1", 1000L, 1, TimeUnit.MICROSECONDS); SingleShotResult r2 = new SingleShotResult(ResultRole.PRIMARY, "Test1", 1000L, 2, TimeUnit.MICROSECONDS); assertEquals(1, r1.getScore(), ASSERT_ACCURACY); assertEquals(0.5, r2.getScore(), ASSERT_ACCURACY); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/TestThroughputResult.java000066400000000000000000000160021446271450100301730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results; import org.junit.Test; import java.util.Arrays; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; public class TestThroughputResult { private static final double ASSERT_ACCURACY = 0.0000001; /** * Test of getScore method, of class ThroughputResult. */ @Test public void testGetScore() { ThroughputResult instance = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MILLISECONDS); assertEquals(1_000, instance.getScore(), 0.0); ThroughputResult instance2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.SECONDS); assertEquals(1_000_000, instance2.getScore(), 0.0); ThroughputResult instance3 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000L, TimeUnit.MILLISECONDS); assertEquals(1_000 / (1_000 / (double) 1_000_000), instance3.getScore(), 0.0); } @Test public void testTimeUnits() { ThroughputResult instanced = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.DAYS); assertEquals(86_400_000_000D, instanced.getScore(), 0.0); assertEquals("ops/day", instanced.getScoreUnit()); ThroughputResult instanceh = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.HOURS); assertEquals(3_600_000_000D, instanceh.getScore(), 0.0); assertEquals("ops/hr", instanceh.getScoreUnit()); ThroughputResult instancem = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MINUTES); assertEquals(60_000_000, instancem.getScore(), 0.0); assertEquals("ops/min", instancem.getScoreUnit()); ThroughputResult instance = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.SECONDS); assertEquals(1_000_000, instance.getScore(), 0.0); assertEquals("ops/s", instance.getScoreUnit()); ThroughputResult instance2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MILLISECONDS); assertEquals(1_000, instance2.getScore(), 0.0); assertEquals("ops/ms", instance2.getScoreUnit()); ThroughputResult instance3 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); assertEquals(1, instance3.getScore(), 0.0); assertEquals("ops/us", instance3.getScoreUnit()); ThroughputResult instance4 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.NANOSECONDS); assertEquals(0.001, instance4.getScore(), 0.0); assertEquals("ops/ns", instance4.getScoreUnit()); } @Test public void testRunAggregator1() { ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 10_000_000L, TimeUnit.MILLISECONDS); ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000L, 10_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(150.0, result.getScore(), ASSERT_ACCURACY); assertEquals("ops/ms", result.getScoreUnit()); } @Test public void testRunAggregator2() { ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 10_000_000L, TimeUnit.MILLISECONDS); ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000L, 20_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(100.0, result.getScore(), ASSERT_ACCURACY); assertEquals("ops/ms", result.getScoreUnit()); } @Test // regression test, check for overflow public void testIterationAggregator3() { ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000_000_000L, 10_000_000L, TimeUnit.MILLISECONDS); ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000_000_000L, 20_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(100_000_000.0, result.getScore(), ASSERT_ACCURACY); assertEquals("ops/ms", result.getScoreUnit()); } @Test public void testThreadAggregator1() { ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 10_000_000L, TimeUnit.MILLISECONDS); ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000L, 10_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals("ops/ms", result.getScoreUnit()); assertEquals(300.0, result.getScore(), ASSERT_ACCURACY); } @Test public void testThreadAggregator2() { ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 10_000_000L, TimeUnit.MILLISECONDS); ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000L, 20_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals("ops/ms", result.getScoreUnit()); assertEquals(200.0, result.getScore(), ASSERT_ACCURACY); } @Test // regression test, check for overflow public void testThreadAggregator3() { ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000_000_000L, 10_000_000L, TimeUnit.MILLISECONDS); ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000_000_000L, 20_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals("ops/ms", result.getScoreUnit()); assertEquals(200_000_000.0, result.getScore(), ASSERT_ACCURACY); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/format/000077500000000000000000000000001446271450100244115ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/format/JSONResultFormatTest.java000066400000000000000000000057671446271450100312540ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results.format; import org.junit.Test; import static org.junit.Assert.*; /** * Extra tests for special cases of the JSON formatter. * * @author Jens Wilke * @see JSONResultFormat */ public class JSONResultFormatTest { @Test public void toJsonString_tidy() { String s = JSONResultFormat.toJsonString("abc,\"{}()\\(\\)[]{}"); s = JSONResultFormat.tidy(s); assertEquals("\"abc,\\\"{}()\\\\(\\\\)[]{}\"\n", s); } @Test public void toJsonString_tidy_curly() { String s = JSONResultFormat.toJsonString("{}"); s = JSONResultFormat.tidy(s); assertEquals("\"{}\"\n", s); } @Test public void toJsonString_tidy_curved() { String s = JSONResultFormat.toJsonString("()"); s = JSONResultFormat.tidy(s); assertEquals("\"()\"\n", s); } @Test public void toJsonString_tidy_escapedDoubleQuote() { String s = JSONResultFormat.toJsonString("\""); s = JSONResultFormat.tidy(s); assertEquals("\"\\\"\"\n", s); } @Test public void toJsonString_tidy_escapedEscape() { String s = JSONResultFormat.toJsonString("\\"); s = JSONResultFormat.tidy(s); assertEquals("\"\\\\\"\n", s); } /** * Check that every ASCII character in a string makes it transparently through * the JSON tidying and formatting process. */ @Test public void toJsonString_tidy_asciiTransparent () { for (char i = 32; i < 127; i++) { if (i == '"') { continue; } if (i == '\\') { continue; } String s = JSONResultFormat.toJsonString(Character.toString(i)); s = JSONResultFormat.tidy(s); assertEquals("\"" + i + "\"\n", s); } } }jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java000066400000000000000000000213571446271450100305530ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.results.format; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; import org.openjdk.jmh.runner.IterationType; import org.openjdk.jmh.runner.WorkloadParams; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.Utils; import java.io.*; import java.util.*; import java.util.concurrent.TimeUnit; /** * These tests seal the machine-readable format. * Any change to these tests should be discussed with the maintainers first! */ public class ResultFormatTest { /** * Use constant dummy for JVM instead of current JVM to compare with golden file. */ private static final String JVM_DUMMY = "javadummy"; /** * Use constant dummy for JVM instead of current JVM to compare with golden file. */ private static final String JDK_VERSION_DUMMY = "1.8-dummy"; private static final String VM_NAME_DUMMY = "DummyVM"; private static final String VM_VERSION_DUMMY = "4711"; private static final String JMH_VERSION_DUMMY = "1.18"; private Collection getStub() { Collection results = new TreeSet<>(RunResult.DEFAULT_SORT_COMPARATOR); Random r = new Random(12345); Random ar = new Random(12345); for (int b = 0; b < r.nextInt(10); b++) { WorkloadParams ps = new WorkloadParams(); ps.put("param0", "value0", 0); ps.put("param1", "[value1]", 1); ps.put("param2", "{value2}", 2); ps.put("param3", "'value3'", 3); ps.put("param4", "\"value4\"", 4); BenchmarkParams params = new BenchmarkParams( "benchmark_" + b, JSONResultFormat.class.getName() + ".benchmark_" + b + "_" + Mode.Throughput, false, r.nextInt(1000), new int[]{ r.nextInt(1000) }, Collections.emptyList(), r.nextInt(1000), r.nextInt(1000), new IterationParams(IterationType.WARMUP, r.nextInt(1000), TimeValue.seconds(r.nextInt(1000)), 1), new IterationParams(IterationType.MEASUREMENT, r.nextInt(1000), TimeValue.seconds(r.nextInt(1000)), 1), Mode.Throughput, ps, TimeUnit.SECONDS, 1, JVM_DUMMY, Collections.emptyList(), JDK_VERSION_DUMMY, VM_NAME_DUMMY, VM_VERSION_DUMMY, JMH_VERSION_DUMMY, TimeValue.days(1)); Collection benchmarkResults = new ArrayList<>(); for (int f = 0; f < r.nextInt(10); f++) { Collection iterResults = new ArrayList<>(); for (int c = 0; c < r.nextInt(10); c++) { IterationResult res = new IterationResult(params, params.getMeasurement(), null); res.addResult(new ThroughputResult(ResultRole.PRIMARY, "test", r.nextInt(1000), 1000 * 1000, TimeUnit.MILLISECONDS)); res.addResult(new ThroughputResult(ResultRole.SECONDARY, "secondary1", r.nextInt(1000), 1000 * 1000, TimeUnit.MILLISECONDS)); res.addResult(new ThroughputResult(ResultRole.SECONDARY, "secondary2", r.nextInt(1000), 1000 * 1000, TimeUnit.MILLISECONDS)); if (ar.nextBoolean()) { res.addResult(new ThroughputResult(ResultRole.SECONDARY, "secondary3", ar.nextInt(1000), 1000 * 1000, TimeUnit.MILLISECONDS)); } iterResults.add(res); } benchmarkResults.add(new BenchmarkResult(params, iterResults)); } results.add(new RunResult(params, benchmarkResults)); } return results; } private void compare(String actualFile, String goldenFile) throws IOException { BufferedReader actualReader = new BufferedReader(new FileReader(actualFile)); BufferedReader goldenReader = new BufferedReader(new InputStreamReader(ResultFormatTest.class.getResourceAsStream("/org/openjdk/jmh/results/format/" + goldenFile))); String actualLines = Utils.join(FileUtils.readAllLines(actualReader), "\n"); String goldenLines = Utils.join(FileUtils.readAllLines(goldenReader), "\n"); Assert.assertEquals("Mismatch", goldenLines, actualLines); } public void test(ResultFormatType type, Locale locale, String suffix) throws IOException { Locale prevLocale = Locale.getDefault(); Locale.setDefault(locale); String actualFileName = "test." + type.toString().toLowerCase() + suffix; String goldenFileName = "output-golden." + type.toString().toLowerCase() + suffix; try { String actualFile = FileUtils.tempFile(actualFileName).getAbsolutePath(); ResultFormatFactory.getInstance(type, actualFile).writeOut(getStub()); compare(actualFile, goldenFileName); PrintStream ps = new PrintStream(actualFile, "UTF-8"); ResultFormatFactory.getInstance(type, ps).writeOut(getStub()); ps.close(); compare(actualFile, goldenFileName); } finally { Locale.setDefault(prevLocale); } } /* * JSON has a strict format for numbers, the results should be Locale-agnostic. */ @Test public void jsonTest_ROOT() throws IOException { test(ResultFormatType.JSON, Locale.ROOT, ""); } @Test public void jsonTest_US() throws IOException { test(ResultFormatType.JSON, Locale.US, ""); } @Test public void jsonTest_RU() throws IOException { test(ResultFormatType.JSON, new Locale("RU"), ""); } /* * CSV and SCSV data should conform to the Locale. */ @Test public void csvTest_ROOT() throws IOException { test(ResultFormatType.CSV, Locale.ROOT, ".root"); } @Test public void csvTest_US() throws IOException { test(ResultFormatType.CSV, Locale.US, ".us"); } @Test public void csvTest_RU() throws IOException { test(ResultFormatType.CSV, new Locale("RU"), ".ru"); } @Test public void scsvTest_ROOT() throws IOException { test(ResultFormatType.SCSV, Locale.ROOT, ".root"); } @Test public void scsvTest_US() throws IOException { test(ResultFormatType.SCSV, Locale.US, ".us"); } @Test public void scsvTest_RU() throws IOException { test(ResultFormatType.SCSV, new Locale("RU"), ".ru"); } /* * LaTeX output should conform to the Locale. */ @Test public void latexTest_ROOT() throws IOException { test(ResultFormatType.LATEX, Locale.ROOT, ".root"); } @Test public void latexTest_US() throws IOException { test(ResultFormatType.LATEX, Locale.US, ".us"); } @Test public void latexTest_RU() throws IOException { test(ResultFormatType.LATEX, new Locale("RU"), ".ru"); } /* * Text output should conform to the Locale. */ @Test public void textTest_ROOT() throws IOException { test(ResultFormatType.TEXT, Locale.ROOT, ".root"); } @Test public void textTest_US() throws IOException { test(ResultFormatType.TEXT, Locale.US, ".us"); } @Test public void textTest_RU() throws IOException { test(ResultFormatType.TEXT, new Locale("RU"), ".ru"); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/000077500000000000000000000000001446271450100227315ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/CompilerHintsTest.java000066400000000000000000000063521446271450100272220ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.util.ArrayList; import java.util.List; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class CompilerHintsTest { private String vmName; @Before public void storeCurrentVM() { vmName = System.getProperty("java.vm.name"); } @Test public void testListNotEmptyForCompliantJvms() { for (String name : CompilerHints.HINT_COMPATIBLE_JVMS) { System.setProperty("java.vm.name", name); CompilerHints.resetCompilerHintsSelect(); List args = new ArrayList<>(); CompilerHints.addCompilerHints(args); assertFalse(args.isEmpty()); } } @Test public void testListEmptyForOldZingJvms() { System.setProperty("java.vm.name", "Zing"); System.setProperty("java.version", "1.7.0-zing_5.9.2.0"); CompilerHints.resetCompilerHintsSelect(); // load up some default hints List args = new ArrayList<>(); CompilerHints.addCompilerHints(args); assertTrue(args.isEmpty()); } @Test public void testListNotEmptyForNewerZingJvms() { System.setProperty("java.vm.name", "Zing"); System.setProperty("java.version", "1.7.0-zing_5.10.2.0"); CompilerHints.resetCompilerHintsSelect(); // load up some default hints List args = new ArrayList<>(); CompilerHints.addCompilerHints(args); assertFalse(args.isEmpty()); } @Test public void testListEmptyForNonCompliantJvms() { System.setProperty("java.vm.name", "StupidVmCantTakeAHint"); CompilerHints.resetCompilerHintsSelect(); List args = new ArrayList<>(); CompilerHints.addCompilerHints(args); assertTrue(args.isEmpty()); } @After public void restoreCurrentVM() { System.setProperty("java.vm.name", vmName); CompilerHints.resetCompilerHintsSelect(); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/DistributeGroupsTest.java000066400000000000000000000353341446271450100277620ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.infra.ThreadParams; import java.util.List; public class DistributeGroupsTest { @Test public void test1() { List controls = BenchmarkHandler.distributeThreads(1, new int[]{1}); Assert.assertEquals(1, controls.size()); // threads agree on thread count, and enumerated Assert.assertEquals(1, controls.get(0).getThreadCount()); Assert.assertEquals(0, controls.get(0).getThreadIndex()); // one group with a single thread Assert.assertEquals(1, controls.get(0).getGroupCount()); Assert.assertEquals(0, controls.get(0).getGroupIndex()); // the thread is alone in the group Assert.assertEquals(1, controls.get(0).getGroupThreadCount()); Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); // no subgroups in the group Assert.assertEquals(1, controls.get(0).getSubgroupCount()); Assert.assertEquals(0, controls.get(0).getSubgroupIndex()); // the thread is alone in the subgroup Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); Assert.assertEquals(0, controls.get(0).getSubgroupThreadIndex()); } @Test public void test2() { List controls = BenchmarkHandler.distributeThreads(2, new int[]{1}); Assert.assertEquals(2, controls.size()); // threads agree on thread count, and enumerated Assert.assertEquals(2, controls.get(0).getThreadCount()); Assert.assertEquals(2, controls.get(1).getThreadCount()); Assert.assertEquals(0, controls.get(0).getThreadIndex()); Assert.assertEquals(1, controls.get(1).getThreadIndex()); // two groups, each for a single thread Assert.assertEquals(2, controls.get(0).getGroupCount()); Assert.assertEquals(2, controls.get(1).getGroupCount()); Assert.assertEquals(0, controls.get(0).getGroupIndex()); Assert.assertEquals(1, controls.get(1).getGroupIndex()); // each thread is alone in the group Assert.assertEquals(1, controls.get(0).getGroupThreadCount()); Assert.assertEquals(1, controls.get(1).getGroupThreadCount()); Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); Assert.assertEquals(0, controls.get(1).getGroupThreadIndex()); // no subgroups in the group Assert.assertEquals(1, controls.get(0).getSubgroupCount()); Assert.assertEquals(1, controls.get(1).getSubgroupCount()); Assert.assertEquals(0, controls.get(0).getSubgroupIndex()); Assert.assertEquals(0, controls.get(1).getSubgroupIndex()); // each thread is alone in the subgroup Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); Assert.assertEquals(1, controls.get(1).getSubgroupThreadCount()); Assert.assertEquals(0, controls.get(0).getSubgroupThreadIndex()); Assert.assertEquals(0, controls.get(1).getSubgroupThreadIndex()); } @Test public void test3() { // First "subgroup" is ignored List controls = BenchmarkHandler.distributeThreads(2, new int[]{0, 1}); Assert.assertEquals(2, controls.size()); // threads agree on thread count, and enumerated Assert.assertEquals(2, controls.get(0).getThreadCount()); Assert.assertEquals(2, controls.get(1).getThreadCount()); Assert.assertEquals(0, controls.get(0).getThreadIndex()); Assert.assertEquals(1, controls.get(1).getThreadIndex()); // two groups, each for a single thread Assert.assertEquals(2, controls.get(0).getGroupCount()); Assert.assertEquals(2, controls.get(1).getGroupCount()); Assert.assertEquals(0, controls.get(0).getGroupIndex()); Assert.assertEquals(1, controls.get(1).getGroupIndex()); // each thread is alone in the group Assert.assertEquals(1, controls.get(0).getGroupThreadCount()); Assert.assertEquals(1, controls.get(1).getGroupThreadCount()); Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); Assert.assertEquals(0, controls.get(1).getGroupThreadIndex()); // two subgroups, but first is not populated Assert.assertEquals(2, controls.get(0).getSubgroupCount()); Assert.assertEquals(2, controls.get(1).getSubgroupCount()); Assert.assertEquals(1, controls.get(0).getSubgroupIndex()); Assert.assertEquals(1, controls.get(1).getSubgroupIndex()); // each thread is alone in the subgroup Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); Assert.assertEquals(1, controls.get(1).getSubgroupThreadCount()); Assert.assertEquals(0, controls.get(0).getSubgroupThreadIndex()); Assert.assertEquals(0, controls.get(1).getSubgroupThreadIndex()); } @Test public void test4() { List controls = BenchmarkHandler.distributeThreads(2, new int[]{1, 1}); Assert.assertEquals(2, controls.size()); // threads agree on thread count, and enumerated Assert.assertEquals(2, controls.get(0).getThreadCount()); Assert.assertEquals(2, controls.get(1).getThreadCount()); Assert.assertEquals(0, controls.get(0).getThreadIndex()); Assert.assertEquals(1, controls.get(1).getThreadIndex()); // one group only Assert.assertEquals(1, controls.get(0).getGroupCount()); Assert.assertEquals(1, controls.get(1).getGroupCount()); Assert.assertEquals(0, controls.get(0).getGroupIndex()); Assert.assertEquals(0, controls.get(1).getGroupIndex()); // both threads share the group Assert.assertEquals(2, controls.get(0).getGroupThreadCount()); Assert.assertEquals(2, controls.get(1).getGroupThreadCount()); Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); Assert.assertEquals(1, controls.get(1).getGroupThreadIndex()); // two subgroups, threads in different subgroups Assert.assertEquals(2, controls.get(0).getSubgroupCount()); Assert.assertEquals(2, controls.get(1).getSubgroupCount()); Assert.assertEquals(0, controls.get(0).getSubgroupIndex()); Assert.assertEquals(1, controls.get(1).getSubgroupIndex()); // each subgroup has a single thread Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); Assert.assertEquals(1, controls.get(1).getSubgroupThreadCount()); Assert.assertEquals(0, controls.get(0).getSubgroupThreadIndex()); Assert.assertEquals(0, controls.get(1).getSubgroupThreadIndex()); } @Test public void test5() { List controls = BenchmarkHandler.distributeThreads(3, new int[]{1, 2}); Assert.assertEquals(3, controls.size()); // threads agree on thread count, and enumerated Assert.assertEquals(3, controls.get(0).getThreadCount()); Assert.assertEquals(3, controls.get(1).getThreadCount()); Assert.assertEquals(3, controls.get(2).getThreadCount()); Assert.assertEquals(0, controls.get(0).getThreadIndex()); Assert.assertEquals(1, controls.get(1).getThreadIndex()); Assert.assertEquals(2, controls.get(2).getThreadIndex()); // one group only Assert.assertEquals(1, controls.get(0).getGroupCount()); Assert.assertEquals(1, controls.get(1).getGroupCount()); Assert.assertEquals(1, controls.get(2).getGroupCount()); Assert.assertEquals(0, controls.get(0).getGroupIndex()); Assert.assertEquals(0, controls.get(1).getGroupIndex()); Assert.assertEquals(0, controls.get(2).getGroupIndex()); // all threads share the group Assert.assertEquals(3, controls.get(0).getGroupThreadCount()); Assert.assertEquals(3, controls.get(1).getGroupThreadCount()); Assert.assertEquals(3, controls.get(2).getGroupThreadCount()); Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); Assert.assertEquals(1, controls.get(1).getGroupThreadIndex()); Assert.assertEquals(2, controls.get(2).getGroupThreadIndex()); // two subgroups, first thread in distinct subgroup Assert.assertEquals(2, controls.get(0).getSubgroupCount()); Assert.assertEquals(2, controls.get(1).getSubgroupCount()); Assert.assertEquals(2, controls.get(2).getSubgroupCount()); Assert.assertEquals(0, controls.get(0).getSubgroupIndex()); Assert.assertEquals(1, controls.get(1).getSubgroupIndex()); Assert.assertEquals(1, controls.get(2).getSubgroupIndex()); // first subgroup has a single thread, second has two threads Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); Assert.assertEquals(2, controls.get(1).getSubgroupThreadCount()); Assert.assertEquals(2, controls.get(2).getSubgroupThreadCount()); Assert.assertEquals(0, controls.get(0).getSubgroupThreadIndex()); Assert.assertEquals(0, controls.get(1).getSubgroupThreadIndex()); Assert.assertEquals(1, controls.get(2).getSubgroupThreadIndex()); } @Test public void test6() { List controls = BenchmarkHandler.distributeThreads(6, new int[]{1, 2}); Assert.assertEquals(6, controls.size()); // threads agree on thread count, and enumerated Assert.assertEquals(6, controls.get(0).getThreadCount()); Assert.assertEquals(6, controls.get(1).getThreadCount()); Assert.assertEquals(6, controls.get(2).getThreadCount()); Assert.assertEquals(6, controls.get(3).getThreadCount()); Assert.assertEquals(6, controls.get(4).getThreadCount()); Assert.assertEquals(6, controls.get(5).getThreadCount()); Assert.assertEquals(0, controls.get(0).getThreadIndex()); Assert.assertEquals(1, controls.get(1).getThreadIndex()); Assert.assertEquals(2, controls.get(2).getThreadIndex()); Assert.assertEquals(3, controls.get(3).getThreadIndex()); Assert.assertEquals(4, controls.get(4).getThreadIndex()); Assert.assertEquals(5, controls.get(5).getThreadIndex()); // two groups Assert.assertEquals(2, controls.get(0).getGroupCount()); Assert.assertEquals(2, controls.get(1).getGroupCount()); Assert.assertEquals(2, controls.get(2).getGroupCount()); Assert.assertEquals(2, controls.get(3).getGroupCount()); Assert.assertEquals(2, controls.get(4).getGroupCount()); Assert.assertEquals(2, controls.get(5).getGroupCount()); Assert.assertEquals(0, controls.get(0).getGroupIndex()); Assert.assertEquals(0, controls.get(1).getGroupIndex()); Assert.assertEquals(0, controls.get(2).getGroupIndex()); Assert.assertEquals(1, controls.get(3).getGroupIndex()); Assert.assertEquals(1, controls.get(4).getGroupIndex()); Assert.assertEquals(1, controls.get(5).getGroupIndex()); // two groups, three threads each Assert.assertEquals(3, controls.get(0).getGroupThreadCount()); Assert.assertEquals(3, controls.get(1).getGroupThreadCount()); Assert.assertEquals(3, controls.get(2).getGroupThreadCount()); Assert.assertEquals(3, controls.get(3).getGroupThreadCount()); Assert.assertEquals(3, controls.get(4).getGroupThreadCount()); Assert.assertEquals(3, controls.get(5).getGroupThreadCount()); Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); Assert.assertEquals(1, controls.get(1).getGroupThreadIndex()); Assert.assertEquals(2, controls.get(2).getGroupThreadIndex()); Assert.assertEquals(0, controls.get(3).getGroupThreadIndex()); Assert.assertEquals(1, controls.get(4).getGroupThreadIndex()); Assert.assertEquals(2, controls.get(5).getGroupThreadIndex()); // two subgroups: first subgroup has a single thread, second has two threads Assert.assertEquals(2, controls.get(0).getSubgroupCount()); Assert.assertEquals(2, controls.get(1).getSubgroupCount()); Assert.assertEquals(2, controls.get(2).getSubgroupCount()); Assert.assertEquals(2, controls.get(3).getSubgroupCount()); Assert.assertEquals(2, controls.get(4).getSubgroupCount()); Assert.assertEquals(2, controls.get(5).getSubgroupCount()); Assert.assertEquals(0, controls.get(0).getSubgroupIndex()); Assert.assertEquals(1, controls.get(1).getSubgroupIndex()); Assert.assertEquals(1, controls.get(2).getSubgroupIndex()); Assert.assertEquals(0, controls.get(3).getSubgroupIndex()); Assert.assertEquals(1, controls.get(4).getSubgroupIndex()); Assert.assertEquals(1, controls.get(5).getSubgroupIndex()); // first subgroup has a single thread, second has two threads Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); Assert.assertEquals(2, controls.get(1).getSubgroupThreadCount()); Assert.assertEquals(2, controls.get(2).getSubgroupThreadCount()); Assert.assertEquals(0, controls.get(3).getSubgroupThreadIndex()); Assert.assertEquals(0, controls.get(4).getSubgroupThreadIndex()); Assert.assertEquals(1, controls.get(5).getSubgroupThreadIndex()); Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); Assert.assertEquals(2, controls.get(1).getSubgroupThreadCount()); Assert.assertEquals(2, controls.get(2).getSubgroupThreadCount()); Assert.assertEquals(0, controls.get(3).getSubgroupThreadIndex()); Assert.assertEquals(0, controls.get(4).getSubgroupThreadIndex()); Assert.assertEquals(1, controls.get(5).getSubgroupThreadIndex()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java000066400000000000000000000171021446271450100257060ustar00rootroot00000000000000/* * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.junit.Test; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.profile.ExternalProfiler; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.Utils; import org.openjdk.jmh.util.Version; import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class RunnerTest { private static final String DUMMY_HOST = "host"; private static final int DUMMY_PORT = 42; static Set defaultHints = CompilerHints.fromFile(CompilerHints.hintsFile()).get(); @Test(expected = IllegalArgumentException.class) public void testNullCheck() { new Runner(null); } @Test public void testEmptyOptsHaveCompileCommandFile() { Runner blade = new Runner(new OptionsBuilder()); BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, 1, new int[]{1}, Collections.emptyList(), 1, 1, new IterationParams(IterationType.WARMUP, 1, TimeValue.seconds(1), 1), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Collections.emptyList(), System.getProperty("java.version"), System.getProperty("java.vm.name"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)); List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); // expecting 1 compile command file List files = CompilerHints.getCompileCommandFiles(command); assertEquals(1, files.size()); // file should exist final String hintFileName = files.get(0); File hintsFile = new File(hintFileName); assertTrue(hintsFile.exists()); // hints should be the default as none were specified Set hints = CompilerHints.fromFile(hintFileName).get(); assertEquals(hints, defaultHints); } @Test public void testOptsWithCompileCommandFileResultInMergedCompileCommandFile() throws IOException { // add a hints file String tempHints = FileUtils.createTempFileWithLines("fileWithLines", Collections.singletonList("inline,we/like/to/move/it.*")); Set extraHints = CompilerHints.fromFile(tempHints).get(); Runner blade = new Runner(new OptionsBuilder().build()); BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, 1, new int[]{1}, Collections.emptyList(), 1, 1, new IterationParams(IterationType.WARMUP, 1, TimeValue.seconds(1), 1), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Collections.singletonList(CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints), System.getProperty("java.version"), System.getProperty("java.vm.name"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)); List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); // expecting 1 compile command file List files = CompilerHints.getCompileCommandFiles(command); assertEquals(1, files.size()); // file should exist final String hintFileName = files.get(0); File hintsFile = new File(hintFileName); assertTrue(hintsFile.exists()); // hints should include defaults and specified Set hints = CompilerHints.fromFile(hintFileName).get(); assertTrue(hints.containsAll(defaultHints)); assertTrue(hints.containsAll(extraHints)); } @Test public void testOptsWith2CompileCommandFilesResultInMergedCompileCommandFile() throws IOException { // add hints files String tempHints1 = FileUtils.createTempFileWithLines("fileWithLines", Collections.singletonList("inline,we/like/to/move/it/move/it.*")); Set extraHints1 = CompilerHints.fromFile(tempHints1).get(); String tempHints2 = FileUtils.createTempFileWithLines("fileWithLines", Collections.singletonList("inline,we/like/to/move/it.*")); Set extraHints2 = CompilerHints.fromFile(tempHints2).get(); Runner blade = new Runner(new OptionsBuilder().build()); BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, 1, new int[]{1}, Collections.emptyList(), 1, 1, new IterationParams(IterationType.WARMUP, 1, TimeValue.seconds(1), 1), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Arrays.asList(CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints1, CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints2), System.getProperty("java.version"), System.getProperty("java.vm.name"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)); List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); // expecting 1 compile command file List files = CompilerHints.getCompileCommandFiles(command); assertEquals(1, files.size()); // file should exist final String hintFileName = files.get(0); File hintsFile = new File(hintFileName); assertTrue(hintsFile.exists()); // hints should include defaults and specified Set hints = CompilerHints.fromFile(hintFileName).get(); assertTrue(hints.containsAll(defaultHints)); assertTrue(hints.containsAll(extraHints1)); assertTrue(hints.containsAll(extraHints2)); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java000066400000000000000000000303251446271450100271650ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.junit.BeforeClass; import org.junit.Test; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.runner.format.OutputFormat; import org.openjdk.jmh.runner.format.OutputFormatFactory; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.util.Optional; import java.util.*; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** * Tests for BenchmarkList */ public class TestBenchmarkList { private static BenchmarkList list; private static OutputFormat out; private static void stub(StringBuilder sb, String userClassQName, String generatedClassQName, String method, Mode mode) { BenchmarkListEntry br = new BenchmarkListEntry( userClassQName, generatedClassQName, method, mode, Optional.none(), new int[]{1}, Optional.>none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.>none(), Optional.>none(), Optional.>none(), Optional.>none(), Optional.none(), Optional.none(), Optional.none() ); sb.append(br.toLine()); sb.append(String.format("%n")); } @BeforeClass public static void setUpClass() { StringBuilder sb = new StringBuilder(); stub(sb, "oracle.micro.benchmarks.api.java.util.concurrent.NormalMaps", "oracle.micro.benchmarks.api.java.util.concurrent.generated.NormalMaps", "testConcurrentHashMap", Mode.AverageTime); stub(sb, "oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap", "oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap", "jbb2005HashMapGetIntThroughput", Mode.AverageTime); stub(sb, "oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap", "oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap", "jbb2005HashMapGetIntGCThroughput", Mode.AverageTime); stub(sb, "oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap", "oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap", "jbb2005HashMapGetIntegerThroughput", Mode.AverageTime); stub(sb, "oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap", "oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap", "jbb2005ResizedHashMapGetIntThroughput", Mode.AverageTime); stub(sb, "oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap", "oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap", "jbb2005ResizedHashMapGetIntegerThroughput", Mode.AverageTime); stub(sb, "oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64", "oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64", "printBase64Binary_128bytesThroughput", Mode.AverageTime); stub(sb, "oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64", "oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64", "printBase64Binary_32bytesThroughput", Mode.AverageTime); stub(sb, "oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64", "oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64", "printBase64Binary_512bytesThroughput", Mode.AverageTime); stub(sb, "oracle.micro.benchmarks.api.java.util.concurrent.GeneratedMaps", "oracle.micro.benchmarks.api.java.util.concurrent.generated.GeneratedMaps", "testConcurrentHashMap", Mode.AverageTime); stub(sb, "org.openjdk.jmh.runner.TestMicro", "org.openjdk.jmh.runner.generated.TestMicro", "dummy", Mode.AverageTime); stub(sb, "org.openjdk.jmh.runner.TestMicro", "org.openjdk.jmh.runner.generated.TestMicro", "dummyWarmThroughput", Mode.AverageTime); stub(sb, "org.openjdk.jmh.runner.TestMicro", "org.openjdk.jmh.runner.generated.TestMicro", "dummyWarmOnlyThroughput", Mode.AverageTime); stub(sb, "org.openjdk.jmh.runner.TestMicro", "org.openjdk.jmh.runner.generated.TestMicro", "dummySetupPayloadThroughput", Mode.AverageTime); stub(sb, "org.openjdk.jmh.runner.TestMicro", "org.openjdk.jmh.runner.generated.TestMicro", "boom_ExceptionThroughput", Mode.AverageTime); stub(sb, "org.openjdk.jmh.runner.TestMicro", "org.openjdk.jmh.runner.generated.TestMicro", "boom_ErrorThroughput", Mode.AverageTime); stub(sb, "org.openjdk.jmh.runner.TestMicro", "org.openjdk.jmh.runner.generated.TestMicro", "boom_ThrowableThroughput", Mode.AverageTime); stub(sb, "org.openjdk.jmh.runner.TestMicro", "org.openjdk.jmh.runner.generated.TestMicro", "blackholedThroughput", Mode.AverageTime); stub(sb, "org.openjdk.jmh.runner.TestBrokenMicro", "org.openjdk.jmh.runner.generated.TestBrokenMicro", "dummyPayloadThroughput", Mode.AverageTime); stub(sb, "org.openjdk.jmh.runner.TestExceptionThrowingMicro", "org.openjdk.jmh.runner.generated.TestExceptionThrowingMicro", "ouchThroughput", Mode.AverageTime); list = BenchmarkList.fromString(sb.toString()); out = OutputFormatFactory.createFormatInstance(System.out, VerboseMode.NORMAL); } @Test public void testListGetNothing() { // make sure we get nothing List excludes = Collections.singletonList(".*"); Set micros = list.getAll(out, excludes); assertEquals(0, micros.size()); } @Test public void testListGetAll() { // make sure we get em all List excludes = Collections.emptyList(); Set micros = list.getAll(out, excludes); assertEquals(20, micros.size()); } @Test public void testListFindSingleByPattern() { // check find without excludes List includes = Collections.singletonList(".*Hash.*"); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); assertEquals(7, micros.size()); } @Test public void testListFindSingleBySubstring() { // check find without excludes List includes = Collections.singletonList("Hash"); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); assertEquals(7, micros.size()); } @Test public void testListFindSingleByTypical() { // check find without excludes // this would be a typical partial pattern with . abuse case List includes = Collections.singletonList("jbb05.GeneratedSPECjbb2005HashMap"); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); assertEquals(5, micros.size()); } @Test public void testListFindAnchored() { // check find without excludes // matches only: org.openjdk.jmh.runner.TestMicro.dummy List includes = Collections.singletonList("^org\\.openjdk.*\\.dummy$"); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); assertEquals(1, micros.size()); } @Test public void testListFindSingleWithExcludes() { // check find with excludes List includes = Collections.singletonList(".*Hash.*"); List excludes = Collections.singletonList(".*Int.*"); Set micros = list.find(out, includes, excludes); assertEquals(2, micros.size()); } @Test public void testListFindAllWithSubstringExclude() { // check find with excludes List includes = Collections.singletonList(""); List excludes = Collections.singletonList("oracle"); Set micros = list.find(out, includes, excludes); assertEquals(10, micros.size()); } @Test public void testListFindAllWithEmpty() { List includes = Collections.emptyList(); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); assertEquals(20, micros.size()); } @Test public void testListFindIncludeList() { // check find with excludes List includes = Arrays.asList("^oracle", ".*openjmh.*"); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); assertEquals(10, micros.size()); } @Test public void testListFindWithIncludesAndExcludes() { List includes = Collections.singletonList(".*Concurrent.*"); List excludes = Collections.singletonList(".*Int.*"); Set micros = list.find(out, includes, excludes); assertEquals(2, micros.size()); } @Test public void testListIsSorted() { // micros should be sorted List includes = Collections.singletonList(".*Hash.*"); List excludes = Collections.singletonList(".*Int.*"); Set micros = list.find(out, includes, excludes); BenchmarkListEntry first = micros.iterator().next(); assertTrue("oracle.micro.benchmarks.api.java.util.concurrent.GeneratedMaps.testConcurrentHashMap".equals(first.getUsername())); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListEncoding.java000066400000000000000000000104251446271450100306330ustar00rootroot00000000000000/* * Copyright (c) 2017, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.junit.Test; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Optional; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.reflect.Field; import java.nio.charset.Charset; import java.util.*; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; public class TestBenchmarkListEncoding { private static BenchmarkListEntry stub(String userClassQName, String generatedClassQName, String method, Mode mode) { BenchmarkListEntry br = new BenchmarkListEntry( userClassQName, generatedClassQName, method, mode, Optional.none(), new int[]{1}, Optional.>none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.>none(), Optional.>none(), Optional.>none(), Optional.>none(), Optional.none(), Optional.none(), Optional.none() ); return br; } @Test public void test_ASCII_UTF8() throws Exception { testWith("ASCII", "UTF-8"); } @Test public void test_UTF8_ASCII() throws Exception { testWith("UTF-8", "ASCII"); } @Test public void test_UTF8_UTF8() throws Exception { testWith("UTF-8", "UTF-8"); } @Test public void test_ASCII_ASCII() throws Exception { testWith("ASCII", "ASCII"); } public void testWith(String src, String dst) throws IOException { BenchmarkListEntry br = stub("something.Test", "something.generated.Test", "testКонкаррентХэшмап", Mode.AverageTime); resetCharset(); System.setProperty("file.encoding", src); ByteArrayOutputStream bos = new ByteArrayOutputStream(); BenchmarkList.writeBenchmarkList(bos, Collections.singleton(br)); resetCharset(); System.setProperty("file.encoding", dst); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); List read = BenchmarkList.readBenchmarkList(bis); assertEquals("something.Test.testКонкаррентХэшмап", read.get(0).getUsername()); } private void resetCharset() { try { Field f = Charset.class.getDeclaredField("defaultCharset"); f.setAccessible(true); f.set(null, null); } catch (Exception e) { // okay then. } } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListSorting.java000066400000000000000000000102701446271450100305300ustar00rootroot00000000000000/* * Copyright (c) 2021, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner; import org.junit.Test; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Optional; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.*; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; public class TestBenchmarkListSorting { private static BenchmarkListEntry stub(String userClassQName, String generatedClassQName, String method, Mode mode) { BenchmarkListEntry br = new BenchmarkListEntry( userClassQName, generatedClassQName, method, mode, Optional.none(), new int[]{1}, Optional.>none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.>none(), Optional.>none(), Optional.>none(), Optional.>none(), Optional.none(), Optional.none(), Optional.none() ); return br; } @Test public void test() throws Exception { BenchmarkListEntry br1 = stub("something.Test1", "something.generated.Test1", "something.generated.TestMethod", Mode.AverageTime); BenchmarkListEntry br2 = stub("something.Test2", "something.generated.Test1", "something.generated.TestMethod", Mode.AverageTime); BenchmarkListEntry br3 = stub("something.Test3", "something.generated.Test1", "something.generated.TestMethod", Mode.AverageTime); BenchmarkListEntry br4 = stub("something.Test4", "something.generated.Test1", "something.generated.TestMethod", Mode.AverageTime); // Present to writer in mixed order ByteArrayOutputStream bos = new ByteArrayOutputStream(); BenchmarkList.writeBenchmarkList(bos, Arrays.asList(br4, br2, br3, br1)); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); List read = BenchmarkList.readBenchmarkList(bis); // Assert we read these in proper order assertEquals("something.Test1", read.get(0).getUserClassQName()); assertEquals("something.Test2", read.get(1).getUserClassQName()); assertEquals("something.Test3", read.get(2).getUserClassQName()); assertEquals("something.Test4", read.get(3).getUserClassQName()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/options/000077500000000000000000000000001446271450100244245ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestIncludes.java000066400000000000000000000040131446271450100276730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import org.junit.Assert; import org.junit.Test; public class TestIncludes { @Test public void testCmdLine_OptBuilder() throws CommandLineOptionException { Options opts = new OptionsBuilder() .parent(new CommandLineOptions()) .include(".*boo.*") .build(); Assert.assertEquals(1, opts.getIncludes().size()); Assert.assertEquals(".*boo.*", opts.getIncludes().get(0)); } @Test public void testOptBuilder_OptBuilder() { Options opts = new OptionsBuilder() .parent(new OptionsBuilder().build()) .include(".*boo.*") .build(); Assert.assertEquals(1, opts.getIncludes().size()); Assert.assertEquals(".*boo.*", opts.getIncludes().get(0)); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java000066400000000000000000000707251446271450100275750ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.results.format.ResultFormatType; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Collection; import java.util.concurrent.TimeUnit; public class TestOptions { private Options EMPTY_BUILDER; private CommandLineOptions EMPTY_CMDLINE; @Before public void setUp() throws Exception { EMPTY_CMDLINE = new CommandLineOptions(); EMPTY_BUILDER = new OptionsBuilder().build(); } @Test public void testSerializable_Cmdline() throws IOException { ObjectOutputStream oos = new ObjectOutputStream(new ByteArrayOutputStream()); oos.writeObject(EMPTY_CMDLINE); oos.flush(); } @Test public void testSerializable_Builder() throws IOException { ObjectOutputStream oos = new ObjectOutputStream(new ByteArrayOutputStream()); oos.writeObject(EMPTY_BUILDER); oos.flush(); } @Test public void testIncludes() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions(".*", ".*test.*", "test"); Options builder = new OptionsBuilder().include(".*").include(".*test.*").include("test").build(); Assert.assertEquals(builder.getIncludes(), cmdLine.getIncludes()); } @Test public void testIncludes_Default() { Assert.assertEquals(EMPTY_BUILDER.getIncludes(), EMPTY_CMDLINE.getIncludes()); } @Test public void testExcludes() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-e", ".*", "-e", ".*test.*", "-e", "test"); Options builder = new OptionsBuilder().exclude(".*").exclude(".*test.*").exclude("test").build(); Assert.assertEquals(builder.getExcludes(), cmdLine.getExcludes()); } @Test public void testExcludes_Default() { Assert.assertEquals(EMPTY_BUILDER.getExcludes(), EMPTY_CMDLINE.getExcludes()); } @Test public void testOutput() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-o", "sample.out"); Options builder = new OptionsBuilder().output("sample.out").build(); Assert.assertEquals(builder.getOutput(), cmdLine.getOutput()); } @Test public void testOutput_Default() { Assert.assertEquals(EMPTY_BUILDER.getOutput(), EMPTY_CMDLINE.getOutput()); } @Test public void testResultFormats() throws Exception { for (ResultFormatType type : ResultFormatType.values()) { CommandLineOptions cmdLine = new CommandLineOptions("-rf", type.toString()); Options builder = new OptionsBuilder().resultFormat(type).build(); Assert.assertEquals(builder.getResultFormat(), cmdLine.getResultFormat()); } } @Test public void testResultFormats_UC() throws Exception { for (ResultFormatType type : ResultFormatType.values()) { CommandLineOptions cmdLine = new CommandLineOptions("-rf", type.toString().toUpperCase()); Options builder = new OptionsBuilder().resultFormat(type).build(); Assert.assertEquals(builder.getResultFormat(), cmdLine.getResultFormat()); } } @Test public void testResultFormats_LC() throws Exception { for (ResultFormatType type : ResultFormatType.values()) { CommandLineOptions cmdLine = new CommandLineOptions("-rf", type.toString().toLowerCase()); Options builder = new OptionsBuilder().resultFormat(type).build(); Assert.assertEquals(builder.getResultFormat(), cmdLine.getResultFormat()); } } @Test public void testResultFormats_Default() { Assert.assertEquals(EMPTY_BUILDER.getResultFormat(), EMPTY_CMDLINE.getResultFormat()); } @Test public void testResult() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-rff", "sample.out"); Options builder = new OptionsBuilder().result("sample.out").build(); Assert.assertEquals(builder.getOutput(), cmdLine.getOutput()); } @Test public void testResult_Default() { Assert.assertEquals(EMPTY_BUILDER.getResult(), EMPTY_CMDLINE.getResult()); } @Test public void testGC_True() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-gc", "true"); Options builder = new OptionsBuilder().shouldDoGC(true).build(); Assert.assertEquals(builder.getOutput(), cmdLine.getOutput()); } @Test public void testGC_False() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-gc", "false"); Options builder = new OptionsBuilder().shouldDoGC(false).build(); Assert.assertEquals(builder.getOutput(), cmdLine.getOutput()); } @Test public void testGC_Default() { Assert.assertEquals(EMPTY_BUILDER.shouldDoGC(), EMPTY_CMDLINE.shouldDoGC()); } @Test public void testProfilers() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-prof", "cl", "-prof", "comp"); Options builder = new OptionsBuilder().addProfiler("cl").addProfiler("comp").build(); Assert.assertEquals(builder.getProfilers(), cmdLine.getProfilers()); } @Test public void testProfilers_Default() { Assert.assertEquals(EMPTY_BUILDER.getProfilers(), EMPTY_CMDLINE.getProfilers()); } @Test public void testVerbose() throws Exception { for (VerboseMode mode : VerboseMode.values()) { CommandLineOptions cmdLine = new CommandLineOptions("-v", mode.toString()); Options builder = new OptionsBuilder().verbosity(mode).build(); Assert.assertEquals(builder.verbosity(), cmdLine.verbosity()); } } @Test public void testVerbose_LC() throws Exception { for (VerboseMode mode : VerboseMode.values()) { CommandLineOptions cmdLine = new CommandLineOptions("-v", mode.toString().toLowerCase()); Options builder = new OptionsBuilder().verbosity(mode).build(); Assert.assertEquals(builder.verbosity(), cmdLine.verbosity()); } } @Test public void testVerbose_UC() throws Exception { for (VerboseMode mode : VerboseMode.values()) { CommandLineOptions cmdLine = new CommandLineOptions("-v", mode.toString().toUpperCase()); Options builder = new OptionsBuilder().verbosity(mode).build(); Assert.assertEquals(builder.verbosity(), cmdLine.verbosity()); } } @Test public void testVerbose_Default() { Assert.assertEquals(EMPTY_BUILDER.verbosity(), EMPTY_CMDLINE.verbosity()); } @Test public void testSFOE_True() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-foe", "true"); Options builder = new OptionsBuilder().shouldFailOnError(true).build(); Assert.assertEquals(builder.shouldFailOnError(), cmdLine.shouldFailOnError()); } @Test public void testSFOE_False() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-foe", "false"); Options builder = new OptionsBuilder().shouldFailOnError(false).build(); Assert.assertEquals(builder.shouldFailOnError(), cmdLine.shouldFailOnError()); } @Test public void testSFOE_Default() { Assert.assertEquals(EMPTY_BUILDER.shouldFailOnError(), EMPTY_CMDLINE.shouldFailOnError()); } @Test public void testThreads_Set() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-t", "2"); Options builder = new OptionsBuilder().threads(2).build(); Assert.assertEquals(builder.getThreads(), cmdLine.getThreads()); } @Test public void testThreads_Max() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-t", "max"); Options builder = new OptionsBuilder().threads(Threads.MAX).build(); Assert.assertEquals(builder.getThreads(), cmdLine.getThreads()); } @Test public void testThreads_Zero() { try { new CommandLineOptions("-t", "0"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '0' of option t. The given value 0 should be positive", e.getMessage()); } } @Test public void testThreads_Zero_OptionsBuilder() { try { new OptionsBuilder().threads(0); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Threads (0) should be positive", e.getMessage()); } } @Test public void testThreads_MinusOne() { try { new CommandLineOptions("-t", "-1"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '-1' of option t. The given value -1 should be positive", e.getMessage()); } } @Test public void testThreads_Minus42() { try { new CommandLineOptions("-t", "-42"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '-42' of option t. The given value -42 should be positive", e.getMessage()); } } @Test public void testThreads_Minus42_OptionsBuilder() { try { new OptionsBuilder().threads(-42); } catch (IllegalArgumentException e) { Assert.assertEquals("Threads (-42) should be positive", e.getMessage()); } } @Test public void testThreads_Default() { Assert.assertEquals(EMPTY_BUILDER.getThreads(), EMPTY_CMDLINE.getThreads()); } @Test public void testThreadGroups() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-tg", "3,4"); Options builder = new OptionsBuilder().threadGroups(3, 4).build(); Assert.assertEquals(builder.getThreads(), cmdLine.getThreads()); } @Test public void testThreadGroups_Default() { Assert.assertEquals(EMPTY_BUILDER.getThreadGroups(), EMPTY_CMDLINE.getThreadGroups()); } @Test public void testThreadGroups_WithZero() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-tg", "3,4,0"); Options builder = new OptionsBuilder().threadGroups(3, 4, 0).build(); Assert.assertEquals(builder.getThreads(), cmdLine.getThreads()); } @Test public void testThreadGroups_AllZero() { try { new CommandLineOptions("-tg", "0,0,0"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Group thread count should be positive, but it is 0", e.getMessage()); } } @Test public void testThreadGroups_AllZero_OptionsBuilder() { try { new OptionsBuilder().threadGroups(0, 0, 0); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Group thread count (0) should be positive", e.getMessage()); } } @Test public void testThreadGroups_WithNegative() { try { new CommandLineOptions("-tg", "-1,-2"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '-1' of option tg. The given value -1 should be non-negative", e.getMessage()); } } @Test public void testThreadGroups_WithNegative_OptionsBuilder() { try { new OptionsBuilder().threadGroups(-1,-2); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Group #0 thread count (-1) should be non-negative", e.getMessage()); } } @Test public void testSynchIterations_True() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-si", "true"); Options builder = new OptionsBuilder().syncIterations(true).build(); Assert.assertEquals(builder.shouldSyncIterations(), cmdLine.shouldSyncIterations()); } @Test public void testSynchIterations_False() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-si", "false"); Options builder = new OptionsBuilder().syncIterations(false).build(); Assert.assertEquals(builder.shouldSyncIterations(), cmdLine.shouldSyncIterations()); } @Test public void testSynchIterations_Default() { Assert.assertEquals(EMPTY_BUILDER.shouldSyncIterations(), EMPTY_CMDLINE.shouldSyncIterations()); } @Test public void testWarmupIterations() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-wi", "34"); Options builder = new OptionsBuilder().warmupIterations(34).build(); Assert.assertEquals(builder.getWarmupIterations(), cmdLine.getWarmupIterations()); } @Test public void testWarmupIterations_Default() { Assert.assertEquals(EMPTY_BUILDER.getWarmupIterations(), EMPTY_CMDLINE.getWarmupIterations()); } @Test public void testWarmupIterations_Zero() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-wi", "0"); Options builder = new OptionsBuilder().warmupIterations(0).build(); Assert.assertEquals(builder.getWarmupIterations(), cmdLine.getWarmupIterations()); } @Test public void testWarmupIterations_MinusOne() { try { new CommandLineOptions("-wi", "-1"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '-1' of option wi. The given value -1 should be non-negative", e.getMessage()); } } @Test public void testWarmupIterations_MinusOne_OptionsBuilder() { try { new OptionsBuilder().warmupIterations(-1); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Warmup iterations (-1) should be non-negative", e.getMessage()); } } @Test public void testWarmupTime() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-w", "34ms"); Options builder = new OptionsBuilder().warmupTime(TimeValue.milliseconds(34)).build(); Assert.assertEquals(builder.getWarmupTime(), cmdLine.getWarmupTime()); } @Test public void testWarmupTime_Default() { Assert.assertEquals(EMPTY_BUILDER.getWarmupTime(), EMPTY_CMDLINE.getWarmupTime()); } @Test public void testRuntimeIterations() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-i", "34"); Options builder = new OptionsBuilder().measurementIterations(34).build(); Assert.assertEquals(builder.getMeasurementIterations(), cmdLine.getMeasurementIterations()); } @Test public void testRuntimeIterations_Default() { Assert.assertEquals(EMPTY_BUILDER.getMeasurementIterations(), EMPTY_CMDLINE.getMeasurementIterations()); } @Test public void testRuntimeIterations_Zero() { try { new CommandLineOptions("-i", "0"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '0' of option i. The given value 0 should be positive", e.getMessage()); } } @Test public void testRuntimeIterations_Zero_OptionsBuilder() { try { new OptionsBuilder().measurementIterations(0); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Measurement iterations (0) should be positive", e.getMessage()); } } @Test public void testRuntime() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-r", "34ms"); Options builder = new OptionsBuilder().measurementTime(TimeValue.milliseconds(34)).build(); Assert.assertEquals(builder.getMeasurementTime(), cmdLine.getMeasurementTime()); } @Test public void testRuntime_Default() { Assert.assertEquals(EMPTY_BUILDER.getMeasurementTime(), EMPTY_CMDLINE.getMeasurementTime()); } @Test public void testWarmupMicros() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-wmb", ".*", "-wmb", ".*test.*", "-wmb", "test"); Options builder = new OptionsBuilder().includeWarmup(".*").includeWarmup(".*test.*").includeWarmup("test").build(); Assert.assertEquals(builder.getWarmupIncludes(), cmdLine.getWarmupIncludes()); } @Test public void testWarmupMicros_Default() { Assert.assertEquals(EMPTY_BUILDER.getWarmupIncludes(), EMPTY_CMDLINE.getWarmupIncludes()); } @Test public void testBenchModes() throws Exception { // TODO: Accept multiple options instead of concatenation? CommandLineOptions cmdLine = new CommandLineOptions("-bm", Mode.AverageTime.shortLabel() + "," + Mode.Throughput.shortLabel()); Options builder = new OptionsBuilder().mode(Mode.AverageTime).mode(Mode.Throughput).build(); Assert.assertEquals(builder.getBenchModes(), cmdLine.getBenchModes()); } @Test public void testBenchModes_Default() { Assert.assertEquals(EMPTY_BUILDER.getBenchModes(), EMPTY_CMDLINE.getBenchModes()); } @Test public void testTimeunit() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-tu", "ns"); Options builder = new OptionsBuilder().timeUnit(TimeUnit.NANOSECONDS).build(); Assert.assertEquals(builder.getTimeUnit(), cmdLine.getTimeUnit()); } @Test public void testTimeunit_Default() { Assert.assertEquals(EMPTY_BUILDER.getTimeUnit(), EMPTY_CMDLINE.getTimeUnit()); } @Test public void testOPI() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-opi", "42"); Options builder = new OptionsBuilder().operationsPerInvocation(42).build(); Assert.assertEquals(builder.getTimeUnit(), cmdLine.getTimeUnit()); } @Test public void testOPI_Zero() { try { new CommandLineOptions("-opi", "0"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '0' of option opi. The given value 0 should be positive", e.getMessage()); } } @Test public void testOPI_Zero_OptionsBuilder() { try { new OptionsBuilder().operationsPerInvocation(0); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Operations per invocation (0) should be positive", e.getMessage()); } } @Test public void testOPI_Default() { Assert.assertEquals(EMPTY_BUILDER.getOperationsPerInvocation(), EMPTY_CMDLINE.getOperationsPerInvocation()); } @Test public void testFork_0() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-f", "0"); Options builder = new OptionsBuilder().forks(0).build(); Assert.assertEquals(builder.getForkCount(), cmdLine.getForkCount()); } @Test public void testFork_1() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-f", "1"); Options builder = new OptionsBuilder().forks(1).build(); Assert.assertEquals(builder.getForkCount(), cmdLine.getForkCount()); } @Test public void testFork_Default() { Assert.assertEquals(EMPTY_BUILDER.getForkCount(), EMPTY_CMDLINE.getForkCount()); } @Test public void testFork_MinusOne() { try { new CommandLineOptions("-f", "-1"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '-1' of option f. The given value -1 should be non-negative", e.getMessage()); } } @Test public void testFork__MinusOne_OptionsBuilder() { try { new OptionsBuilder().forks(-1); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Forks (-1) should be non-negative", e.getMessage()); } } @Test public void testWarmupFork_0() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-wf", "0"); Options builder = new OptionsBuilder().warmupForks(0).build(); Assert.assertEquals(builder.getWarmupForkCount(), cmdLine.getWarmupForkCount()); } @Test public void testWarmupFork_1() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-wf", "1"); Options builder = new OptionsBuilder().warmupForks(1).build(); Assert.assertEquals(builder.getWarmupForkCount(), cmdLine.getWarmupForkCount()); } @Test public void testWarmupFork_Default() { Assert.assertEquals(EMPTY_BUILDER.getWarmupForkCount(), EMPTY_CMDLINE.getWarmupForkCount()); } @Test public void testWarmupFork_MinusOne() { try { new CommandLineOptions("-wf", "-1"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '-1' of option wf. The given value -1 should be non-negative", e.getMessage()); } } @Test public void testWarmupFork_MinusOne_OptionsBuilder() { try { new OptionsBuilder().warmupForks(-1); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Warmup forks (-1) should be non-negative", e.getMessage()); } } @Test public void testJvm() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("--jvm", "sample.jar"); Options builder = new OptionsBuilder().jvm("sample.jar").build(); Assert.assertEquals(builder.getJvm(), cmdLine.getJvm()); } @Test public void testJvm_Default() { Assert.assertEquals(EMPTY_BUILDER.getJvm(), EMPTY_CMDLINE.getJvm()); } @Test public void testJvmArgs() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("--jvmArgs", "sample.jar"); Options builder = new OptionsBuilder().jvmArgs("sample.jar").build(); Assert.assertEquals(builder.getJvmArgs(), cmdLine.getJvmArgs()); } @Test public void testJvmArgs_Default() { Assert.assertEquals(EMPTY_BUILDER.getJvmArgs(), EMPTY_CMDLINE.getJvmArgs()); } @Test public void testJvmArgsAppend() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("--jvmArgsAppend", "sample.jar"); Options builder = new OptionsBuilder().jvmArgsAppend("sample.jar").build(); Assert.assertEquals(builder.getJvmArgsAppend(), cmdLine.getJvmArgsAppend()); } @Test public void testJvmArgsAppend_Default() { Assert.assertEquals(EMPTY_BUILDER.getJvmArgsAppend(), EMPTY_CMDLINE.getJvmArgsAppend()); } @Test public void testJvmArgsPrepend() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("--jvmArgsPrepend", "sample.jar"); Options builder = new OptionsBuilder().jvmArgsPrepend("sample.jar").build(); Assert.assertEquals(builder.getJvmArgsPrepend(), cmdLine.getJvmArgsPrepend()); } @Test public void testJvmArgsPrepend_Default() { Assert.assertEquals(EMPTY_BUILDER.getJvmArgsPrepend(), EMPTY_CMDLINE.getJvmArgsPrepend()); } @Test public void testBatchSize() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-bs", "42"); Options builder = new OptionsBuilder().measurementBatchSize(42).build(); Assert.assertEquals(builder.getMeasurementBatchSize(), cmdLine.getMeasurementBatchSize()); } @Test public void testBatchSize_Default() { Assert.assertEquals(EMPTY_BUILDER.getMeasurementBatchSize(), EMPTY_CMDLINE.getMeasurementBatchSize()); } @Test public void testBatchSize_Zero() { try { new CommandLineOptions("-bs", "0"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '0' of option bs. The given value 0 should be positive", e.getMessage()); } } @Test public void testBatchSize_Zero_OptionsBuilder() { try { new OptionsBuilder().measurementBatchSize(0); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Measurement batch size (0) should be positive", e.getMessage()); } } @Test public void testWarmupBatchSize() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-wbs", "43"); Options builder = new OptionsBuilder().warmupBatchSize(43).build(); Assert.assertEquals(builder.getWarmupBatchSize(), cmdLine.getWarmupBatchSize()); } @Test public void testWarmupBatchSize_Default() { Assert.assertEquals(EMPTY_BUILDER.getWarmupBatchSize(), EMPTY_CMDLINE.getWarmupBatchSize()); } @Test public void testWarmupBatchSize_Zero() { try { new CommandLineOptions("-wbs", "0"); Assert.fail(); } catch (CommandLineOptionException e) { Assert.assertEquals("Cannot parse argument '0' of option wbs. The given value 0 should be positive", e.getMessage()); } } @Test public void testWarmupBatchSize_Zero_OptionsBuilder() { try { new OptionsBuilder().warmupBatchSize(0); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Warmup batch size (0) should be positive", e.getMessage()); } } @Test public void testParam_Default() { Assert.assertEquals(EMPTY_BUILDER.getParameter("sample"), EMPTY_CMDLINE.getParameter("sample")); } @Test public void testParam() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-p", "x=1,2,3"); Options builder = new OptionsBuilder().param("x", "1", "2", "3").build(); Collection bp = builder.getParameter("x").get(); Collection cp = cmdLine.getParameter("x").get(); for (String b : bp) { Assert.assertTrue("CP does not contain: " + b, cp.contains(b)); } for (String c : cp) { Assert.assertTrue("BP does not contain: " + c, bp.contains(c)); } } @Test public void testParam_EmptyString() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-p", "x="); Options builder = new OptionsBuilder().param("x", "").build(); Collection bp = builder.getParameter("x").get(); Collection cp = cmdLine.getParameter("x").get(); for (String b : bp) { Assert.assertTrue("CP does not contain: " + b, cp.contains(b)); } for (String c : cp) { Assert.assertTrue("BP does not contain: " + c, bp.contains(c)); } } @Test public void testTimeout() throws Exception { CommandLineOptions cmdLine = new CommandLineOptions("-to", "34ms"); Options builder = new OptionsBuilder().timeout(TimeValue.milliseconds(34)).build(); Assert.assertEquals(builder.getTimeout(), cmdLine.getTimeout()); } @Test public void testTimeout_Default() { Assert.assertEquals(EMPTY_BUILDER.getTimeout(), EMPTY_CMDLINE.getTimeout()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestParentOptions.java000066400000000000000000000622201446271450100307360ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.options; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.results.format.ResultFormatType; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.concurrent.TimeUnit; public class TestParentOptions { @Test public void testIncludes_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getIncludes().isEmpty()); } @Test public void testIncludes_Parent() { Options parent = new OptionsBuilder().include(".*").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Collections.singletonList(".*"), builder.getIncludes()); } @Test public void testIncludes_Merge() { Options parent = new OptionsBuilder().include(".*").build(); Options builder = new OptionsBuilder().parent(parent).include(".*test.*").build(); Assert.assertEquals(Arrays.asList(".*test.*", ".*"), builder.getIncludes()); } @Test public void testExcludes_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getExcludes().isEmpty()); } @Test public void testExcludes_Parent() { Options parent = new OptionsBuilder().include(".*").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Collections.singletonList(".*"), builder.getIncludes()); } @Test public void testExcludes_Merge() { Options parent = new OptionsBuilder().exclude(".*").build(); Options builder = new OptionsBuilder().parent(parent).exclude(".*test.*").build(); Assert.assertEquals(Arrays.asList(".*test.*", ".*"), builder.getExcludes()); } @Test public void testProfiler_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getProfilers().isEmpty()); } @Test public void testProfiler_Parent() { Options parent = new OptionsBuilder().addProfiler("cl").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getProfilers().size() == 1); Assert.assertTrue(builder.getProfilers().contains(new ProfilerConfig("cl", ""))); } @Test public void testProfiler_Merge() { Options parent = new OptionsBuilder().addProfiler("cl").build(); Options builder = new OptionsBuilder().parent(parent).addProfiler("comp").build(); Assert.assertTrue(builder.getProfilers().size() == 2); Assert.assertTrue(builder.getProfilers().contains(new ProfilerConfig("cl", ""))); Assert.assertTrue(builder.getProfilers().contains(new ProfilerConfig("comp", ""))); } @Test public void testBenchModes_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getBenchModes().isEmpty()); } @Test public void testBenchModes_Parent() { Options parent = new OptionsBuilder().mode(Mode.AverageTime).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(EnumSet.of(Mode.AverageTime), builder.getBenchModes()); } @Test public void testBenchModes_Merge() { Options parent = new OptionsBuilder().mode(Mode.AverageTime).build(); Options builder = new OptionsBuilder().parent(parent).mode(Mode.SingleShotTime).build(); Assert.assertEquals(EnumSet.of(Mode.SingleShotTime), builder.getBenchModes()); } @Test public void testForks_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getForkCount().hasValue()); } @Test public void testForks_Parent() { Options parent = new OptionsBuilder().forks(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getForkCount().get()); } @Test public void testForks_Merge() { Options parent = new OptionsBuilder().forks(42).build(); Options builder = new OptionsBuilder().parent(parent).forks(84).build(); Assert.assertEquals(Integer.valueOf(84), builder.getForkCount().get()); } @Test public void testGC_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.shouldDoGC().hasValue()); } @Test public void testGC_Parent() { Options parent = new OptionsBuilder().shouldDoGC(true).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(true, builder.shouldDoGC().get()); } @Test public void testGC_Merge() { Options parent = new OptionsBuilder().shouldDoGC(true).build(); Options builder = new OptionsBuilder().parent(parent).shouldDoGC(false).build(); Assert.assertEquals(false, builder.shouldDoGC().get()); } @Test public void testJVM_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getJvm().hasValue()); } @Test public void testJVM_Parent() { Options parent = new OptionsBuilder().jvm("path").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals("path", builder.getJvm().get()); } @Test public void testJVM_Merge() { Options parent = new OptionsBuilder().jvm("path").build(); Options builder = new OptionsBuilder().parent(parent).jvm("path2").build(); Assert.assertEquals("path2", builder.getJvm().get()); } @Test public void testJVMArgs_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getJvmArgs().hasValue()); } @Test public void testJVMArgs_Parent() { Options parent = new OptionsBuilder().jvmArgs("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Arrays.asList("opt1", "opt2"), builder.getJvmArgs().get()); } @Test public void testJVMArgs_Merge() { Options parent = new OptionsBuilder().jvmArgs("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).jvmArgs("opt3", "opt4").build(); Assert.assertEquals(Arrays.asList("opt3", "opt4"), builder.getJvmArgs().get()); } @Test public void testJVMArgsAppend_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getJvmArgsAppend().hasValue()); } @Test public void testJVMArgsAppend_Parent() { Options parent = new OptionsBuilder().jvmArgsAppend("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Arrays.asList("opt1", "opt2"), builder.getJvmArgsAppend().get()); } @Test public void testJVMArgsAppend_Merge() { Options parent = new OptionsBuilder().jvmArgsAppend("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).jvmArgsAppend("opt3", "opt4").build(); Assert.assertEquals(Arrays.asList("opt3", "opt4"), builder.getJvmArgsAppend().get()); } @Test public void testJVMArgsPrepend_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getJvmArgsPrepend().hasValue()); } @Test public void testJVMArgsPrepend_Parent() { Options parent = new OptionsBuilder().jvmArgsPrepend("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Arrays.asList("opt1", "opt2"), builder.getJvmArgsPrepend().get()); } @Test public void testJVMArgsPrepend_Merge() { Options parent = new OptionsBuilder().jvmArgsPrepend("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).jvmArgsPrepend("opt3", "opt4").build(); Assert.assertEquals(Arrays.asList("opt3", "opt4"), builder.getJvmArgsPrepend().get()); } @Test public void testOutput_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getOutput().hasValue()); } @Test public void testOutput_Parent() { Options parent = new OptionsBuilder().output("out1").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals("out1", builder.getOutput().get()); } @Test public void testOutput_Merged() { Options parent = new OptionsBuilder().output("out1").build(); Options builder = new OptionsBuilder().parent(parent).output("out2").build(); Assert.assertEquals("out2", builder.getOutput().get()); } @Test public void testResult_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getResult().hasValue()); } @Test public void testResult_Parent() { Options parent = new OptionsBuilder().result("out1").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals("out1", builder.getResult().get()); } @Test public void testResult_Merged() { Options parent = new OptionsBuilder().result("out1").build(); Options builder = new OptionsBuilder().parent(parent).result("out2").build(); Assert.assertEquals("out2", builder.getResult().get()); } @Test public void testResultFormat_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getResultFormat().hasValue()); } @Test public void testResultFormat_Parent() { Options parent = new OptionsBuilder().resultFormat(ResultFormatType.JSON).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(ResultFormatType.JSON, builder.getResultFormat().get()); } @Test public void testResultFormat_Merged() { Options parent = new OptionsBuilder().resultFormat(ResultFormatType.JSON).build(); Options builder = new OptionsBuilder().parent(parent).resultFormat(ResultFormatType.SCSV).build(); Assert.assertEquals(ResultFormatType.SCSV, builder.getResultFormat().get()); } @Test public void testRuntime_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getMeasurementTime().hasValue()); } @Test public void testRuntime_Parent() { Options parent = new OptionsBuilder().measurementTime(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(TimeValue.hours(42), builder.getMeasurementTime().get()); } @Test public void testRuntime_Merged() { Options parent = new OptionsBuilder().measurementTime(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).measurementTime(TimeValue.days(42)).build(); Assert.assertEquals(TimeValue.days(42), builder.getMeasurementTime().get()); } @Test public void testMeasureIters_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getMeasurementIterations().hasValue()); } @Test public void testMeasureIters_Parent() { Options parent = new OptionsBuilder().measurementIterations(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getMeasurementIterations().get()); } @Test public void testMeasureIters_Merged() { Options parent = new OptionsBuilder().measurementIterations(42).build(); Options builder = new OptionsBuilder().parent(parent).measurementIterations(84).build(); Assert.assertEquals(Integer.valueOf(84), builder.getMeasurementIterations().get()); } @Test public void testSFOE_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.shouldFailOnError().hasValue()); } @Test public void testSFOE_Parent() { Options parent = new OptionsBuilder().shouldFailOnError(true).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(true, builder.shouldFailOnError().get()); } @Test public void testSFOE_Merged() { Options parent = new OptionsBuilder().shouldFailOnError(true).build(); Options builder = new OptionsBuilder().parent(parent).shouldFailOnError(false).build(); Assert.assertEquals(false, builder.shouldFailOnError().get()); } @Test public void testSyncIters_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.shouldSyncIterations().hasValue()); } @Test public void testSyncIters_Parent() { Options parent = new OptionsBuilder().syncIterations(true).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(true, builder.shouldSyncIterations().get()); } @Test public void testSyncIters_Merged() { Options parent = new OptionsBuilder().syncIterations(true).build(); Options builder = new OptionsBuilder().parent(parent).syncIterations(false).build(); Assert.assertEquals(false, builder.shouldSyncIterations().get()); } @Test public void testThreadGroups_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getThreadGroups().hasValue()); } @Test public void testThreadGroups_Parent() { Options parent = new OptionsBuilder().threadGroups(1, 2).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertArrayEquals(new int[]{1, 2}, builder.getThreadGroups().get()); } @Test public void testThreadGroups_Merged() { Options parent = new OptionsBuilder().threadGroups(1, 2).build(); Options builder = new OptionsBuilder().parent(parent).threadGroups(3, 4).build(); Assert.assertArrayEquals(new int[]{3, 4}, builder.getThreadGroups().get()); } @Test public void testThreads_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getThreads().hasValue()); } @Test public void testThreads_Parent() { Options parent = new OptionsBuilder().threads(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getThreads().get()); } @Test public void testThreads_Merged() { Options parent = new OptionsBuilder().threads(42).build(); Options builder = new OptionsBuilder().parent(parent).threads(84).build(); Assert.assertEquals(Integer.valueOf(84), builder.getThreads().get()); } @Test public void testTimeUnit_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getTimeUnit().hasValue()); } @Test public void testTimeUnit_Parent() { Options parent = new OptionsBuilder().timeUnit(TimeUnit.DAYS).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(TimeUnit.DAYS, builder.getTimeUnit().get()); } @Test public void testTimeUnit_Merged() { Options parent = new OptionsBuilder().timeUnit(TimeUnit.DAYS).build(); Options builder = new OptionsBuilder().parent(parent).timeUnit(TimeUnit.HOURS).build(); Assert.assertEquals(TimeUnit.HOURS, builder.getTimeUnit().get()); } @Test public void testOPI_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getOperationsPerInvocation().hasValue()); } @Test public void testOPI_Parent() { Options parent = new OptionsBuilder().operationsPerInvocation(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getOperationsPerInvocation().get()); } @Test public void testOPI_Merged() { Options parent = new OptionsBuilder().operationsPerInvocation(42).build(); Options builder = new OptionsBuilder().parent(parent).operationsPerInvocation(43).build(); Assert.assertEquals(Integer.valueOf(43), builder.getOperationsPerInvocation().get()); } @Test public void testVerbose_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.verbosity().hasValue()); } @Test public void testVerbose_Parent() { Options parent = new OptionsBuilder().verbosity(VerboseMode.EXTRA).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(VerboseMode.EXTRA, builder.verbosity().get()); } @Test public void testVerbose_Merged() { Options parent = new OptionsBuilder().verbosity(VerboseMode.EXTRA).build(); Options builder = new OptionsBuilder().parent(parent).verbosity(VerboseMode.SILENT).build(); Assert.assertEquals(VerboseMode.SILENT, builder.verbosity().get()); } @Test public void testWarmupForks_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getWarmupForkCount().hasValue()); } @Test public void testWarmupForks_Parent() { Options parent = new OptionsBuilder().warmupForks(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getWarmupForkCount().get()); } @Test public void testWarmupForks_Merge() { Options parent = new OptionsBuilder().warmupForks(42).build(); Options builder = new OptionsBuilder().parent(parent).warmupForks(84).build(); Assert.assertEquals(Integer.valueOf(84), builder.getWarmupForkCount().get()); } @Test public void testWarmupIters_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getWarmupIterations().hasValue()); } @Test public void testWarmupIters_Parent() { Options parent = new OptionsBuilder().warmupIterations(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getWarmupIterations().get()); } @Test public void testWarmupIters_Merged() { Options parent = new OptionsBuilder().warmupIterations(42).build(); Options builder = new OptionsBuilder().parent(parent).warmupIterations(84).build(); Assert.assertEquals(Integer.valueOf(84), builder.getWarmupIterations().get()); } @Test public void testWarmupTime_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getWarmupTime().hasValue()); } @Test public void testWarmupTime_Parent() { Options parent = new OptionsBuilder().warmupTime(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(TimeValue.hours(42), builder.getWarmupTime().get()); } @Test public void testWarmupTime_Merged() { Options parent = new OptionsBuilder().warmupTime(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).warmupTime(TimeValue.days(42)).build(); Assert.assertEquals(TimeValue.days(42), builder.getWarmupTime().get()); } @Test public void testWarmupMicros_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getWarmupIncludes().isEmpty()); } @Test public void testWarmupMicros_Parent() { Options parent = new OptionsBuilder().includeWarmup(".*").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Collections.singletonList(".*"), builder.getWarmupIncludes()); } @Test public void testWarmupMicros_Merged() { Options parent = new OptionsBuilder().includeWarmup(".*").build(); Options builder = new OptionsBuilder().parent(parent).includeWarmup(".*test.*").build(); Assert.assertEquals(Arrays.asList(".*test.*", ".*"), builder.getWarmupIncludes()); } @Test public void testParameters_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getParameter("x").hasValue()); } @Test public void testParameters_Parent() { Options parent = new OptionsBuilder().param("x", "1", "2", "3").build(); Options builder = new OptionsBuilder().parent(parent).build(); Collection bp = builder.getParameter("x").get(); Assert.assertEquals(3, bp.size()); for (String b : new String[] {"1", "2", "3"}) { Assert.assertTrue("BP does not contain: " + b, bp.contains(b)); } } @Test public void testParameters_Merged() { Options parent = new OptionsBuilder().param("x", "1", "2", "3").build(); Options builder = new OptionsBuilder().parent(parent).param("x", "4", "5", "6").build(); Collection bp = builder.getParameter("x").get(); Assert.assertEquals(3, bp.size()); for (String b : new String[] {"4", "5", "6"}) { Assert.assertTrue("BP does not contain: " + b, bp.contains(b)); } } @Test public void testTimeout_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getTimeout().hasValue()); } @Test public void testTimeout_Parent() { Options parent = new OptionsBuilder().timeout(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(TimeValue.hours(42), builder.getTimeout().get()); } @Test public void testTimeout_Merged() { Options parent = new OptionsBuilder().timeout(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).timeout(TimeValue.days(42)).build(); Assert.assertEquals(TimeValue.days(42), builder.getTimeout().get()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/parameters/000077500000000000000000000000001446271450100250745ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/runner/parameters/TimeValueTest.java000066400000000000000000000060231446271450100304730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.runner.parameters; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.runner.options.TimeValue; import java.util.concurrent.TimeUnit; public class TimeValueTest { @Test public void testNano() { TimeValue v = TimeValue.fromString(TimeValue.nanoseconds(10).toString()); Assert.assertEquals(TimeUnit.NANOSECONDS, v.getTimeUnit()); Assert.assertEquals(10, v.getTime()); } @Test public void testMicro() { TimeValue v = TimeValue.fromString(TimeValue.microseconds(10).toString()); Assert.assertEquals(TimeUnit.MICROSECONDS, v.getTimeUnit()); Assert.assertEquals(10, v.getTime()); } @Test public void testMilli() { TimeValue v = TimeValue.fromString(TimeValue.milliseconds(10).toString()); Assert.assertEquals(TimeUnit.MILLISECONDS, v.getTimeUnit()); Assert.assertEquals(10, v.getTime()); } @Test public void testSeconds() { TimeValue v = TimeValue.fromString(TimeValue.seconds(10).toString()); Assert.assertEquals(TimeUnit.SECONDS, v.getTimeUnit()); Assert.assertEquals(10, v.getTime()); } @Test public void testMinutes() { TimeValue v = TimeValue.fromString(TimeValue.minutes(10).toString()); Assert.assertEquals(TimeUnit.MINUTES, v.getTimeUnit()); Assert.assertEquals(10, v.getTime()); } @Test public void testHours() { TimeValue v = TimeValue.fromString(TimeValue.hours(10).toString()); Assert.assertEquals(TimeUnit.HOURS, v.getTimeUnit()); Assert.assertEquals(10, v.getTime()); } @Test public void testDays() { TimeValue v = TimeValue.fromString(TimeValue.days(10).toString()); Assert.assertEquals(TimeUnit.DAYS, v.getTimeUnit()); Assert.assertEquals(10, v.getTime()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/000077500000000000000000000000001446271450100223755ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/BoundedPriorityQueueTest.java000066400000000000000000000045371446271450100302400ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.junit.Assert; import org.junit.Test; import java.util.Collections; import java.util.Queue; public class BoundedPriorityQueueTest { @Test public void top3Smallest() { Queue queue = new BoundedPriorityQueue<>(3); queue.add(50); queue.add(40); queue.add(10); queue.add(20); queue.add(30); queue.add(30); queue.add(80); Assert.assertEquals(3, queue.size()); Assert.assertEquals((Integer) 30, queue.poll()); Assert.assertEquals((Integer) 20, queue.poll()); Assert.assertEquals((Integer) 10, queue.poll()); } @Test public void top3Largest() { Queue queue = new BoundedPriorityQueue<>(3, Collections.reverseOrder()); queue.add(50); queue.add(40); queue.add(10); queue.add(20); queue.add(30); queue.add(30); queue.add(80); Assert.assertEquals(3, queue.size()); Assert.assertEquals((Integer) 40, queue.poll()); Assert.assertEquals((Integer) 50, queue.poll()); Assert.assertEquals((Integer) 80, queue.poll()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/MultisetTest.java000066400000000000000000000042401446271450100257060ustar00rootroot00000000000000/* * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import static org.junit.Assert.*; import org.junit.Test; public class MultisetTest { @Test public void testClear() { Multiset set = new HashMultiset<>(); set.add("one"); set.add("two", 2); assertFalse(set.isEmpty()); assertEquals(3, set.size()); assertEquals(2, set.keys().size()); assertEquals(1, set.count("one")); assertEquals(2, set.count("two")); // clear the set set.clear(); assertTrue(set.isEmpty()); assertEquals(0, set.size()); assertEquals(0, set.keys().size()); assertEquals(0, set.count("one")); assertEquals(0, set.count("two")); // reuse the set set.add("one"); set.add("two", 2); assertFalse(set.isEmpty()); assertEquals(3, set.size()); assertEquals(2, set.keys().size()); assertEquals(1, set.count("one")); assertEquals(2, set.count("two")); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/MultisetsTest.java000066400000000000000000000054101446271450100260710ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.junit.Assert; import org.junit.Test; import java.util.List; public class MultisetsTest { @Test public void testCountHighest() { Multiset set = new HashMultiset<>(); set.add(10); set.add(10); set.add(10); set.add(20); set.add(20); set.add(70); List topInts = Multisets.countHighest(set, 2); Assert.assertEquals(2, topInts.size()); Assert.assertEquals((Integer) 10, topInts.get(0)); Assert.assertEquals((Integer) 20, topInts.get(1)); } @Test public void testCountHighest_2() { // Regression test for CODETOOLS-7901411 Multiset set = new HashMultiset<>(); set.add("Meh", 85); set.add("Blah", 17); set.add("Choo", 1); List top = Multisets.countHighest(set, 3); Assert.assertEquals(3, top.size()); Assert.assertEquals("Meh", top.get(0)); Assert.assertEquals("Blah", top.get(1)); Assert.assertEquals("Choo", top.get(2)); } @Test public void testSortedDesc() { Multiset set = new HashMultiset<>(); set.add(10); set.add(10); set.add(10); set.add(20); set.add(20); set.add(70); List topInts = Multisets.sortedDesc(set); Assert.assertEquals(3, topInts.size()); Assert.assertEquals((Integer) 10, topInts.get(0)); Assert.assertEquals((Integer) 20, topInts.get(1)); Assert.assertEquals((Integer) 70, topInts.get(2)); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java000066400000000000000000000070261446271450100261730ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.junit.Assert; import org.junit.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; public class TestClassUtils { @Test public void testDenseClasses1() { List src = Arrays.asList("org.openjdk.benches.ForkJoinTest.test1", "org.openjdk.benches.ForkJoinTest.test2", "org.openjdk.benches.AnotherTest.test0"); Map map = ClassUtils.denseClassNames(src); Assert.assertEquals("ForkJoinTest.test1", map.get("org.openjdk.benches.ForkJoinTest.test1")); Assert.assertEquals("ForkJoinTest.test2", map.get("org.openjdk.benches.ForkJoinTest.test2")); } @Test public void testDenseClasses2() { List src = Collections.singletonList("org.openjdk.benches.ForkJoinTest.test1"); Map map = ClassUtils.denseClassNames(src); Assert.assertEquals("ForkJoinTest.test1", map.get("org.openjdk.benches.ForkJoinTest.test1")); } @Test public void testDenseClasses3() { List src = Collections.singletonList("org.openjdk.benches.ForkJoinTest.test1:label1"); Map map = ClassUtils.denseClassNames(src); Assert.assertEquals("ForkJoinTest.test1:label1", map.get("org.openjdk.benches.ForkJoinTest.test1:label1")); } @Test public void testDifferentPackages() { List src = Arrays.asList("com.some.even.longer.word.SomeEvenMoreWeirdBenchmark", "my.sample.pkg.MySampleBenchmark", "test.jmh.TestJmhBenchmark"); Map map = ClassUtils.denseClassNames(src); Assert.assertEquals("com.some.even.longer.word.SomeEvenMoreWeirdBenchmark", map.get("com.some.even.longer.word.SomeEvenMoreWeirdBenchmark")); Assert.assertEquals("my.sample.pkg.MySampleBenchmark", map.get("my.sample.pkg.MySampleBenchmark")); Assert.assertEquals("test.jmh.TestJmhBenchmark", map.get("test.jmh.TestJmhBenchmark")); } @Test public void testSemiDifferentPackages() { List src = Arrays.asList("com.some.Benchmark", "com.some2.Benchmark2"); Map map = ClassUtils.denseClassNames(src); Assert.assertEquals("c.some.Benchmark", map.get("com.some.Benchmark")); Assert.assertEquals("c.some2.Benchmark2", map.get("com.some2.Benchmark2")); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/TestFileUtils.java000066400000000000000000000031521446271450100260010ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.junit.Test; import java.io.File; import static org.junit.Assert.assertTrue; /** * Test for FileUtils */ public class TestFileUtils { @Test public void testExtractFromResource() throws Exception { File test = FileUtils.extractFromResource("/org/openjdk/jmh/results/format/output-golden.json"); test.deleteOnExit(); assertTrue(test.exists()); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java000066400000000000000000000324221446271450100270710ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; import static org.junit.Assert.assertEquals; /** * Tests for Statistics */ public class TestListStatistics { private static final double[] VALUES = { 60.89053178, 3.589312005, 42.73638635, 85.55397805, 96.66786311, 29.31809699, 63.50268147, 52.24157468, 64.68049085, 2.34517545, 92.62435741, 7.50775664, 31.92395987, 82.68609724, 71.07171954, 15.78967174, 34.43339987, 65.40063304, 69.86288638, 22.55130769, 36.99130073, 60.17648239, 33.1484382, 56.4605944, 93.67454206 }; private static final double ASSERT_ACCURACY = 0.0000000001; private static final ListStatistics instance = new ListStatistics(); @BeforeClass public static void setUpClass() { for (double value : VALUES) { instance.addValue(value); } } /** * Test of add method, of class Statistics. */ @Test public strictfp void testAdd_double() { ListStatistics stats = new ListStatistics(); stats.addValue(VALUES[0]); assertEquals(1, stats.getN()); assertEquals(VALUES[0], stats.getSum(), 0.0); assertEquals(VALUES[0], stats.getMax(), 0.0); assertEquals(VALUES[0], stats.getMin(), 0.0); assertEquals(VALUES[0], stats.getMean(), 0.0); assertEquals(Double.NaN, stats.getVariance(), 0.0); assertEquals(Double.NaN, stats.getStandardDeviation(), 0.0); } /** * Test of getN method, of class Statistics. */ @Test public strictfp void testGetN() { assertEquals(VALUES.length, instance.getN()); } /** * Test of getSum method, of class Statistics. */ @Test public strictfp void testGetSum() { assertEquals(1275.829, instance.getSum(), 0.001); } /** * Test of getMean method, of class Statistics. */ @Test public strictfp void testGetMean() { assertEquals(51.033, instance.getMean(), 0.001); } /** * Test of getMax method, of class Statistics. */ @Test public strictfp void testGetMax() { assertEquals(96.66786311, instance.getMax(), 0.0); } /** * Test of getMin method, of class Statistics. */ @Test public strictfp void testGetMin() { assertEquals(2.34517545, instance.getMin(), 0.0); } /** * Test of getVariance method, of class Statistics. */ @Test public strictfp void testGetVariance() { assertEquals(816.9807, instance.getVariance(), 0.0001); } /** * Test of getStandardDeviation method, of class Statistics. */ @Test public strictfp void testGetStandardDeviation() { assertEquals(28.5828, instance.getStandardDeviation(), 0.0001); } /** * Test of getConfidenceIntervalAt, of class Statistics */ @Test public strictfp void testGetConfidenceInterval() { double[] interval = instance.getConfidenceIntervalAt(0.999); assertEquals(29.62232, interval[0], 0.002); assertEquals(72.44402, interval[1], 0.002); } @Test public strictfp void testPercentile_00() { assertEquals(2.345, instance.getPercentile(0), 0.002); } @Test public strictfp void testPercentile_50() { assertEquals(56.460, instance.getPercentile(50), 0.002); } @Test public strictfp void testPercentile_90() { assertEquals(93.044, instance.getPercentile(90), 0.002); } @Test public strictfp void testPercentile_99() { assertEquals(96.667, instance.getPercentile(99), 0.002); } @Test public strictfp void testPercentile_100() { assertEquals(96.667, instance.getPercentile(100), 0.002); } /** * Test of toString, of class Statistics */ @Test public strictfp void testToString() { String expResult = "N:25 Mean: 51.03316951740001 Min: 2.34517545 Max: 96.66786311 StdDev: 28.582874479178013"; String result = instance.toString(); assertEquals(expResult, result); } @Test public strictfp void testSignificant_Always() { ListStatistics s1 = new ListStatistics(); ListStatistics s2 = new ListStatistics(); for (int c = 0; c < 10; c++) { s1.addValue(1); s1.addValue(1.1); s2.addValue(2); s2.addValue(2.1); } for (double conf : new double[] {0.5, 0.9, 0.99, 0.999, 0.9999, 0.99999}) { Assert.assertTrue("Diff significant at " + conf, s1.isDifferent(s2, conf)); Assert.assertTrue(s1.compareTo(s2, conf) < 0); } } @Test public strictfp void testSignificant_Never() { ListStatistics s1 = new ListStatistics(); ListStatistics s2 = new ListStatistics(); for (int c = 0; c < 10; c++) { s1.addValue(1); s1.addValue(1.1); s2.addValue(1); s2.addValue(1.1); } for (double conf : new double[] {0.5, 0.9, 0.99, 0.999, 0.9999, 0.99999}) { Assert.assertFalse("Diff not significant at " + conf, s1.isDifferent(s2, conf)); Assert.assertEquals(0, s1.compareTo(s2, conf)); } } @Test public strictfp void testSignificant_Sometimes() { ListStatistics s1 = new ListStatistics(); ListStatistics s2 = new ListStatistics(); for (int c = 0; c < 10; c++) { s1.addValue(1); s1.addValue(2); s2.addValue(1); s2.addValue(3); } Assert.assertTrue("Diff significant at 0.5", s1.isDifferent(s2, 0.5)); Assert.assertTrue("Diff significant at 0.9", s1.isDifferent(s2, 0.9)); Assert.assertFalse("Diff not significant at 0.99", s1.isDifferent(s2, 0.99)); Assert.assertFalse("Diff not significant at 0.999", s1.isDifferent(s2, 0.999)); Assert.assertFalse("Diff not significant at 0.9999", s1.isDifferent(s2, 0.9999)); Assert.assertTrue("compareTo at 0.5", s1.compareTo(s2, 0.5) < 0); Assert.assertTrue("compareTo at 0.9", s1.compareTo(s2, 0.9) < 0); Assert.assertEquals("compareTo at 0.99", 0, s1.compareTo(s2, 0.99)); Assert.assertEquals("compareTo at 0.999", 0, s1.compareTo(s2, 0.999)); Assert.assertEquals("compareTo at 0.9999", 0, s1.compareTo(s2, 0.9999)); } @Test public strictfp void testEmpty() { Statistics s = new ListStatistics(); Assert.assertEquals(0, s.getN()); Assert.assertEquals(Double.NaN, s.getSum(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMin(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMax(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMean(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getVariance(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getStandardDeviation(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0], ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getPercentile(0), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getPercentile(100), ASSERT_ACCURACY); } @Test public strictfp void testSingle() { ListStatistics s = new ListStatistics(); s.addValue(42.0D); Assert.assertEquals(1, s.getN()); Assert.assertEquals(42.0D, s.getSum(), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getMin(), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getMax(), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getMean(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getVariance(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getStandardDeviation(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0], ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getPercentile(0), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getPercentile(100), ASSERT_ACCURACY); } @Test public strictfp void testHistogram_MinMax() { ListStatistics s = new ListStatistics(); s.addValue(42.5); Util.assertHistogram(s, new double[] {Double.MIN_VALUE, Double.MAX_VALUE}, new int[] {1} ); } @Test public strictfp void testHistogram_42_43() { ListStatistics s = new ListStatistics(); s.addValue(42.5); Util.assertHistogram(s, new double[] {42, 43}, new int[] {1} ); } @Test public strictfp void testHistogram_0_42() { ListStatistics s = new ListStatistics(); s.addValue(42.5); Util.assertHistogram(s, new double[] {0, 42}, new int[] {0} ); } @Test public strictfp void testHistogram_43_100() { ListStatistics s = new ListStatistics(); s.addValue(42.5); Util.assertHistogram(s, new double[] {43, 100}, new int[] {0} ); } @Test public strictfp void testHistogram_leftBound() { ListStatistics s = new ListStatistics(); s.addValue(10); Util.assertHistogram(s, new double[] {10, 100}, new int[] {1} ); } @Test public strictfp void testHistogram_rightBound() { ListStatistics s = new ListStatistics(); s.addValue(10); Util.assertHistogram(s, new double[] {0, 10}, new int[] {0} ); } @Test public strictfp void testHistogram_emptyLevels_left() { ListStatistics s = new ListStatistics(); s.addValue(9); Util.assertHistogram(s, new double[] {0, 2, 4, 8, 10}, new int[] {0, 0, 0, 1} ); } @Test public strictfp void testHistogram_emptyLevels_right() { ListStatistics s = new ListStatistics(); s.addValue(1); Util.assertHistogram(s, new double[] {0, 2, 4, 8, 10}, new int[] {1, 0, 0, 0} ); } @Test public strictfp void testHistogram_emptyLevels_middle() { ListStatistics s = new ListStatistics(); s.addValue(5); Util.assertHistogram(s, new double[] {0, 2, 4, 8, 10}, new int[] {0, 0, 1, 0} ); } @Test public strictfp void testHistogram_increasing() { ListStatistics s = new ListStatistics(); for (int c = 0; c <= 10; c++) { for (int t = 0; t < c; t++) { s.addValue(c * 10); } } Util.assertHistogram(s, new double[] {0, 200}, new int[] {55} ); Util.assertHistogram(s, new double[] {0, 50, 101}, new int[] {10, 45} ); Util.assertHistogram(s, new double[] {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ); } /** * Test of iterator which make accessible raw data. */ @Test public strictfp void testRawDataIterator() { Iterator> listIter = instance.getRawData(); for (double item : VALUES) { Assert.assertTrue(listIter.hasNext()); Map.Entry entry = listIter.next(); Assert.assertEquals(entry.getKey(), item, ASSERT_ACCURACY); Assert.assertEquals(1L, entry.getValue().longValue()); } Assert.assertFalse(listIter.hasNext()); try { listIter.next(); Assert.fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // expected } } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java000066400000000000000000000353611446271450100277710ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; import static org.junit.Assert.assertEquals; /** * Tests for Statistics */ public class TestMultisetStatistics { private static final double[] VALUES = { 60.89053178, 3.589312005, 42.73638635, 85.55397805, 96.66786311, 29.31809699, 63.50268147, 52.24157468, 64.68049085, 2.34517545, 92.62435741, 7.50775664, 31.92395987, 82.68609724, 71.07171954, 15.78967174, 34.43339987, 65.40063304, 69.86288638, 22.55130769, 36.99130073, 60.17648239, 33.1484382, 56.4605944, 93.67454206 }; private static final double ASSERT_ACCURACY = 0.000000001; private static final MultisetStatistics instance = new MultisetStatistics(); @BeforeClass public static void setUpClass() { for (double value : VALUES) { instance.addValue(value, 1); } } /** * Test of add method, of class Statistics. */ @Test public strictfp void testAdd_double() { MultisetStatistics stats = new MultisetStatistics(); stats.addValue(VALUES[0], 1); assertEquals(1, stats.getN()); assertEquals(VALUES[0], stats.getSum(), 0.0); assertEquals(VALUES[0], stats.getMax(), 0.0); assertEquals(VALUES[0], stats.getMin(), 0.0); assertEquals(VALUES[0], stats.getMean(), 0.0); assertEquals(Double.NaN, stats.getVariance(), 0.0); assertEquals(Double.NaN, stats.getStandardDeviation(), 0.0); } /** * Test of getN method, of class Statistics. */ @Test public strictfp void testGetN() { assertEquals(VALUES.length, instance.getN()); } /** * Test of getSum method, of class Statistics. */ @Test public strictfp void testGetSum() { assertEquals(1275.829, instance.getSum(), 0.001); } /** * Test of getMean method, of class Statistics. */ @Test public strictfp void testGetMean() { assertEquals(51.033, instance.getMean(), 0.001); } /** * Test of getMax method, of class Statistics. */ @Test public strictfp void testGetMax() { assertEquals(96.66786311, instance.getMax(), 0.0); } /** * Test of getMin method, of class Statistics. */ @Test public strictfp void testGetMin() { assertEquals(2.34517545, instance.getMin(), 0.0); } /** * Test of getVariance method, of class Statistics. */ @Test public strictfp void testGetVariance() { assertEquals(816.9807, instance.getVariance(), 0.0001); } /** * Test of getStandardDeviation method, of class Statistics. */ @Test public strictfp void testGetStandardDeviation() { assertEquals(28.5828, instance.getStandardDeviation(), 0.0001); } /** * Test of getConfidenceIntervalAt, of class Statistics */ @Test public strictfp void testGetConfidenceInterval() { double[] interval = instance.getConfidenceIntervalAt(0.999); assertEquals(29.62232, interval[0], 0.002); assertEquals(72.44402, interval[1], 0.002); } @Test public strictfp void testPercentile_00() { assertEquals(2.345, instance.getPercentile(0), 0.002); } @Test public strictfp void testPercentile_50() { assertEquals(56.460, instance.getPercentile(50), 0.002); } @Test public strictfp void testPercentile_90() { assertEquals(93.044, instance.getPercentile(90), 0.002); } @Test public strictfp void testPercentile_99() { assertEquals(96.667, instance.getPercentile(99), 0.002); } @Test public strictfp void testPercentile_100() { assertEquals(96.667, instance.getPercentile(100), 0.002); } /** * Test of toString, of class Statistics */ @Test public strictfp void testToString() { String expResult = "N:25 Mean: 51.033169517400005 Min: 2.34517545 Max: 96.66786311 StdDev: 28.582874479178017"; String result = instance.toString(); assertEquals(expResult, result); } @Test public strictfp void testSignificant_Always() { MultisetStatistics s1 = new MultisetStatistics(); MultisetStatistics s2 = new MultisetStatistics(); s1.addValue(1, 10); s1.addValue(1.1, 10); s2.addValue(2, 10); s2.addValue(2.1, 10); for (double conf : new double[] {0.5, 0.9, 0.99, 0.999, 0.9999, 0.99999}) { Assert.assertTrue("Diff significant at " + conf, s1.isDifferent(s2, conf)); Assert.assertTrue(s1.compareTo(s2, conf) < 0); } } @Test public strictfp void testSignificant_Never() { MultisetStatistics s1 = new MultisetStatistics(); MultisetStatistics s2 = new MultisetStatistics(); s1.addValue(1, 10); s1.addValue(1.1, 10); s2.addValue(1, 10); s2.addValue(1.1, 10); for (double conf : new double[] {0.5, 0.9, 0.99, 0.999, 0.9999, 0.99999}) { Assert.assertFalse("Diff not significant at " + conf, s1.isDifferent(s2, conf)); Assert.assertEquals(0, s1.compareTo(s2, conf)); } } @Test public strictfp void testSignificant_Sometimes() { MultisetStatistics s1 = new MultisetStatistics(); MultisetStatistics s2 = new MultisetStatistics(); s1.addValue(1, 10); s1.addValue(2, 10); s2.addValue(1, 10); s2.addValue(3, 10); Assert.assertTrue("Diff significant at 0.5", s1.isDifferent(s2, 0.5)); Assert.assertTrue("Diff significant at 0.9", s1.isDifferent(s2, 0.9)); Assert.assertFalse("Diff not significant at 0.99", s1.isDifferent(s2, 0.99)); Assert.assertFalse("Diff not significant at 0.999", s1.isDifferent(s2, 0.999)); Assert.assertFalse("Diff not significant at 0.9999", s1.isDifferent(s2, 0.9999)); Assert.assertTrue("compareTo at 0.5", s1.compareTo(s2, 0.5) < 0); Assert.assertTrue("compareTo at 0.9", s1.compareTo(s2, 0.9) < 0); Assert.assertEquals("compareTo at 0.99", 0, s1.compareTo(s2, 0.99)); Assert.assertEquals("compareTo at 0.999", 0, s1.compareTo(s2, 0.999)); Assert.assertEquals("compareTo at 0.9999", 0, s1.compareTo(s2, 0.9999)); } @Test public strictfp void testEmpty() { Statistics s = new MultisetStatistics(); Assert.assertEquals(0, s.getN()); Assert.assertEquals(Double.NaN, s.getSum(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMin(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMax(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMean(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getVariance(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getStandardDeviation(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0], ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getPercentile(0), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getPercentile(100), ASSERT_ACCURACY); } @Test public strictfp void testSingle() { MultisetStatistics s = new MultisetStatistics(); s.addValue(42.0D, 1); Assert.assertEquals(1, s.getN()); Assert.assertEquals(42.0D, s.getSum(), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getMin(), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getMax(), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getMean(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getVariance(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getStandardDeviation(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0], ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getPercentile(0), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getPercentile(100), ASSERT_ACCURACY); } @Test public strictfp void testHistogram_MinMax() { MultisetStatistics s = new MultisetStatistics(); s.addValue(42.5, 1); Util.assertHistogram(s, new double[] {Double.MIN_VALUE, Double.MAX_VALUE}, new int[] {1} ); } @Test public strictfp void testHistogram_42_43() { MultisetStatistics s = new MultisetStatistics(); s.addValue(42.5, 1); Util.assertHistogram(s, new double[] {42, 43}, new int[] {1} ); } @Test public strictfp void testHistogram_0_42() { MultisetStatistics s = new MultisetStatistics(); s.addValue(42.5, 1); Util.assertHistogram(s, new double[] {0, 42}, new int[] {0} ); } @Test public strictfp void testHistogram_43_100() { MultisetStatistics s = new MultisetStatistics(); s.addValue(42.5, 1); Util.assertHistogram(s, new double[] {43, 100}, new int[] {0} ); } @Test public strictfp void testHistogram_leftBound() { MultisetStatistics s = new MultisetStatistics(); s.addValue(10, 1); Util.assertHistogram(s, new double[] {10, 100}, new int[] {1} ); } @Test public strictfp void testHistogram_rightBound() { MultisetStatistics s = new MultisetStatistics(); s.addValue(10, 1); Util.assertHistogram(s, new double[] {0, 10}, new int[] {0} ); } @Test public strictfp void testHistogram_emptyLevels_left() { MultisetStatistics s = new MultisetStatistics(); s.addValue(9, 1); Util.assertHistogram(s, new double[] {0, 2, 4, 8, 10}, new int[] {0, 0, 0, 1} ); } @Test public strictfp void testHistogram_emptyLevels_right() { MultisetStatistics s = new MultisetStatistics(); s.addValue(1, 1); Util.assertHistogram(s, new double[] {0, 2, 4, 8, 10}, new int[] {1, 0, 0, 0} ); } @Test public strictfp void testHistogram_emptyLevels_middle() { MultisetStatistics s = new MultisetStatistics(); s.addValue(5, 1); Util.assertHistogram(s, new double[] {0, 2, 4, 8, 10}, new int[] {0, 0, 1, 0} ); } @Test public strictfp void testHistogram_increasing() { MultisetStatistics s = new MultisetStatistics(); for (int c = 0; c <= 10; c++) { s.addValue(c * 10, c); } Util.assertHistogram(s, new double[] {0, 200}, new int[] {55} ); Util.assertHistogram(s, new double[] {0, 50, 101}, new int[] {10, 45} ); Util.assertHistogram(s, new double[] {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ); } /** * Test of iterator which make accessible raw data. * Iterate over default instance with no duplicates. */ @Test public strictfp void testRawDataIterator_no_duplicates() { int itemCount = 0; Iterator> it = instance.getRawData(); for (Map.Entry entry : Utils.adaptForLoop(it)) { Assert.assertEquals(entry.getValue().longValue(), 1L); // Check if key (the actual data) is in the VALUES collection, // else fail the test (the Multiset was constructed with values // from VALUES collection, so it should be there). boolean keyIsPresent = false; double key = entry.getKey(); for (double value : VALUES) { if (Double.compare(value, key) == 0) { keyIsPresent = true; break; } } Assert.assertTrue("Value from iterator is not present in source collection", keyIsPresent); itemCount++; } Assert.assertEquals(itemCount, VALUES.length); Assert.assertFalse(it.hasNext()); try { it.next(); Assert.fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // expected } } /** * Test of iterator which make accessible raw data. * Iterate over new instance with duplicates. */ @Test public strictfp void testRawDataIterator_duplicates() { MultisetStatistics s = new MultisetStatistics(); for (int c = 0; c <= 10; c++) { s.addValue(c * 10, c); } Iterator> it = s.getRawData(); int itemCount = 0; for (Map.Entry entry : Utils.adaptForLoop(it)) { Assert.assertEquals(entry.getKey(), (double)(entry.getValue() * 10), ASSERT_ACCURACY); itemCount++; } Assert.assertEquals(itemCount, 10); Assert.assertFalse(it.hasNext()); try { it.next(); Assert.fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // expected } } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java000066400000000000000000000204371446271450100301230ustar00rootroot00000000000000/* * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; import static org.junit.Assert.assertEquals; /** * Tests for Statistics */ public class TestSingletonStatistics { private static final double VALUE = 42.73638635; private static final double ASSERT_ACCURACY = 0.000000001; private static final ListStatistics listStats = new ListStatistics(); private static final SingletonStatistics singStats = new SingletonStatistics(VALUE); @BeforeClass public static void setUpClass() { listStats.addValue(VALUE); } /** * Test of getN method, of class Statistics. */ @Test public strictfp void testGetN() { assertEquals(listStats.getN(), singStats.getN()); } /** * Test of getSum method, of class Statistics. */ @Test public strictfp void testGetSum() { assertEquals(listStats.getSum(), singStats.getSum(), 0.001); } /** * Test of getMean method, of class Statistics. */ @Test public strictfp void testGetMean() { assertEquals(listStats.getMean(), singStats.getMean(), 0.001); } /** * Test of getMax method, of class Statistics. */ @Test public strictfp void testGetMax() { assertEquals(listStats.getMax(), singStats.getMax(), 0.001); } /** * Test of getMin method, of class Statistics. */ @Test public strictfp void testGetMin() { assertEquals(listStats.getMin(), singStats.getMin(), 0.001); } /** * Test of getVariance method, of class Statistics. */ @Test public strictfp void testGetVariance() { assertEquals(listStats.getVariance(), singStats.getVariance(), 0.001); } /** * Test of getStandardDeviation method, of class Statistics. */ @Test public strictfp void testGetStandardDeviation() { assertEquals(listStats.getStandardDeviation(), singStats.getStandardDeviation(), 0.001); } /** * Test of getConfidenceIntervalAt, of class Statistics */ @Test public strictfp void testGetConfidenceInterval() { double[] listInterval = listStats.getConfidenceIntervalAt(0.999); double[] singInterval = singStats.getConfidenceIntervalAt(0.999); assertEquals(listInterval[0], singInterval[0], 0.001); assertEquals(listInterval[1], singInterval[1], 0.001); } @Test public strictfp void testPercentile_00() { assertEquals(listStats.getPercentile(0), singStats.getPercentile(0), 0.002); } @Test public strictfp void testPercentile_50() { assertEquals(listStats.getPercentile(50), singStats.getPercentile(50), 0.002); } @Test public strictfp void testPercentile_90() { assertEquals(listStats.getPercentile(90), singStats.getPercentile(90), 0.002); } @Test public strictfp void testPercentile_99() { assertEquals(listStats.getPercentile(99), singStats.getPercentile(99), 0.002); } @Test public strictfp void testPercentile_100() { assertEquals(listStats.getPercentile(100), singStats.getPercentile(100), 0.002); } @Test public strictfp void testSingle() { SingletonStatistics s = new SingletonStatistics(42.0D); Assert.assertEquals(1, s.getN()); Assert.assertEquals(42.0D, s.getSum(), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getMin(), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getMax(), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getMean(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getVariance(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getStandardDeviation(), ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0], ASSERT_ACCURACY); Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getPercentile(0), ASSERT_ACCURACY); Assert.assertEquals(42.0D, s.getPercentile(100), ASSERT_ACCURACY); } @Test public strictfp void testHistogram_MinMax() { SingletonStatistics s = new SingletonStatistics(42.5); Util.assertHistogram(s, new double[] {Double.MIN_VALUE, Double.MAX_VALUE}, new int[] {1} ); } @Test public strictfp void testHistogram_42_43() { SingletonStatistics s = new SingletonStatistics(42.5); Util.assertHistogram(s, new double[] {42, 43}, new int[] {1} ); } @Test public strictfp void testHistogram_0_42() { SingletonStatistics s = new SingletonStatistics(42.5); Util.assertHistogram(s, new double[] {0, 42}, new int[] {0} ); } @Test public strictfp void testHistogram_43_100() { SingletonStatistics s = new SingletonStatistics(42.5); Util.assertHistogram(s, new double[] {43, 100}, new int[] {0} ); } @Test public strictfp void testHistogram_leftBound() { SingletonStatistics s = new SingletonStatistics(10); Util.assertHistogram(s, new double[] {10, 100}, new int[] {1} ); } @Test public strictfp void testHistogram_rightBound() { SingletonStatistics s = new SingletonStatistics(10); Util.assertHistogram(s, new double[] {0, 10}, new int[] {0} ); } @Test public strictfp void testHistogram_emptyLevels_left() { SingletonStatistics s = new SingletonStatistics(9); Util.assertHistogram(s, new double[] {0, 2, 4, 8, 10}, new int[] {0, 0, 0, 1} ); } @Test public strictfp void testHistogram_emptyLevels_right() { SingletonStatistics s = new SingletonStatistics(1); Util.assertHistogram(s, new double[] {0, 2, 4, 8, 10}, new int[] {1, 0, 0, 0} ); } @Test public strictfp void testHistogram_emptyLevels_middle() { SingletonStatistics s = new SingletonStatistics(5); Util.assertHistogram(s, new double[] {0, 2, 4, 8, 10}, new int[] {0, 0, 1, 0} ); } /** * Test of iterator which make accessible raw data. */ @Test public strictfp void testRawDataIterator() { Iterator> singIter = singStats.getRawData(); Assert.assertTrue(singIter.hasNext()); Map.Entry entry = singIter.next(); Assert.assertEquals(entry.getKey(), VALUE, ASSERT_ACCURACY); Assert.assertEquals(entry.getValue().longValue(), 1L); Assert.assertFalse(singIter.hasNext()); try { singIter.next(); Assert.fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // expected } } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/TestUtil.java000066400000000000000000000046241446271450100250230ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.junit.Assert; import org.junit.Test; import java.io.IOException; import java.util.Arrays; public class TestUtil { @Test public void testPID_Current() { Assert.assertTrue(Utils.getPid() != 0); } @Test public void testPID_Other() throws IOException, InterruptedException { if (!Utils.isWindows()) { ProcessBuilder pb = new ProcessBuilder().command("sleep", "1"); Process p = pb.start(); Assert.assertTrue(Utils.getPid(p) != 0); p.waitFor(); } } @Test public void testSplit() { Assert.assertEquals(Arrays.asList("moo"), Utils.splitQuotedEscape("moo")); Assert.assertEquals(Arrays.asList("moo", "bar"), Utils.splitQuotedEscape("moo bar")); Assert.assertEquals(Arrays.asList("moo", "bar"), Utils.splitQuotedEscape("moo bar")); Assert.assertEquals(Arrays.asList("moo", "bar", "baz"), Utils.splitQuotedEscape("moo bar baz")); Assert.assertEquals(Arrays.asList("moo", "bar baz"), Utils.splitQuotedEscape("moo \"bar baz\"")); Assert.assertEquals(Arrays.asList("moo", "-Dopt=bar baz"), Utils.splitQuotedEscape("moo -Dopt=\"bar baz\"")); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/Util.java000066400000000000000000000032651446271450100241630ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util; import org.junit.Assert; import java.util.Arrays; public class Util { public static void assertHistogram(Statistics s, double[] vals, int[] expected) { int[] actual = s.getHistogram(vals); Assert.assertEquals(expected.length, actual.length); Assert.assertTrue( "Expected " + Arrays.toString(expected) + ", but got " + Arrays.toString(actual), Arrays.equals(expected, actual)); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/lines/000077500000000000000000000000001446271450100235075ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/lines/TestArmor.java000066400000000000000000000055731446271450100263040ustar00rootroot00000000000000/* * Copyright (c) 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util.lines; import org.junit.Assert; import org.junit.Test; import java.util.Random; public class TestArmor { @Test public void simple() { String[] srcs = new String[] { "jmh", "test" }; for (String src : srcs) { Assert.assertEquals(src, src, Armor.decode(Armor.encode(src))); } } @Test public void exhaustivePlaces() { for (char c = 0; c < Character.MAX_VALUE; c++) { testFour(c, (char)0, (char)0, (char)0); testFour((char)0, c, (char)0, (char)0); testFour((char)0, (char)0, c, (char)0); testFour((char)0, (char)0, (char)0, c); } } private void testFour(char c1, char c2, char c3, char c4) { StringBuilder sb = new StringBuilder(); sb.append(c1); sb.append(c2); sb.append(c3); sb.append(c4); String src = sb.toString(); String dst = Armor.decode(Armor.encode(src)); Assert.assertEquals(src, src, dst); } @Test public void random() { Random r = new Random(1); for (int c = 0; c < 100000; c++) { for (int s = 0; s < 10; s++) { testWith(r, s, 127); testWith(r, s, 255); testWith(r, s, Character.MAX_VALUE - 10); } } } private void testWith(Random r, int size, int maxChar) { StringBuilder sb = new StringBuilder(); for (int s = 0; s < size; s++) { sb.append((char)r.nextInt(maxChar)); } String src = sb.toString(); String dst = Armor.decode(Armor.encode(src)); Assert.assertEquals(src, src, dst); } } jmh-1.37/jmh-core/src/test/java/org/openjdk/jmh/util/lines/TestLineTest.java000066400000000000000000000111461446271450100267440ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.util.lines; import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Optional; import org.openjdk.jmh.util.lines.TestLineReader; import org.openjdk.jmh.util.lines.TestLineWriter; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; public class TestLineTest { @Test public void test() { TestLineWriter writer = new TestLineWriter(); writer.putString("jmh"); writer.putString("test"); writer.putOptionalString(Optional.eitherOf("full-optional")); writer.putOptionalString(Optional.none()); writer.putOptionalInt(Optional.eitherOf(42)); writer.putOptionalInt(Optional.none()); writer.putIntArray(new int[] {5, 3, 2}); writer.putOptionalTimeValue(Optional.eitherOf(TimeValue.milliseconds(14))); writer.putOptionalTimeValue(Optional.none()); writer.putOptionalTimeUnit(Optional.eitherOf(TimeUnit.HOURS)); writer.putOptionalTimeUnit(Optional.none()); writer.putOptionalStringCollection(Optional.>eitherOf(Arrays.asList("foo", "bar", "baz"))); writer.putOptionalStringCollection(Optional.>none()); HashMap expectedMap = new HashMap<>(); expectedMap.put("key1", new String[] {"val1", "val2"}); expectedMap.put("key2", new String[] {"val3", "val4"}); expectedMap.put("key3", new String[] {"val5\r", "val6"}); expectedMap.put("key4", new String[] {"val7\rn", "val8\n"}); writer.putOptionalParamCollection(Optional.>eitherOf(expectedMap)); writer.putOptionalParamCollection(Optional.>none()); String s = writer.toString(); TestLineReader reader = new TestLineReader(s); Assert.assertEquals("jmh", reader.nextString()); Assert.assertEquals("test", reader.nextString()); Assert.assertEquals("full-optional", reader.nextOptionalString().get()); Assert.assertEquals(false, reader.nextOptionalString().hasValue()); Assert.assertEquals(42, (int)reader.nextOptionalInt().get()); Assert.assertEquals(false, reader.nextOptionalInt().hasValue()); Assert.assertTrue(Arrays.equals(new int[] {5, 3, 2}, reader.nextIntArray())); Assert.assertEquals(TimeValue.milliseconds(14), reader.nextOptionalTimeValue().get()); Assert.assertEquals(false, reader.nextOptionalTimeValue().hasValue()); Assert.assertEquals(TimeUnit.HOURS, reader.nextOptionalTimeUnit().get()); Assert.assertEquals(false, reader.nextOptionalTimeUnit().hasValue()); Assert.assertEquals(Arrays.asList("foo", "bar", "baz"), reader.nextOptionalStringCollection().get()); Assert.assertEquals(false, reader.nextOptionalStringCollection().hasValue()); Map actualMap = reader.nextOptionalParamCollection().get(); Assert.assertEquals(expectedMap.size(), actualMap.size()); Assert.assertEquals(expectedMap.keySet(), actualMap.keySet()); for (String key : expectedMap.keySet()) { String[] expectedVals = expectedMap.get(key); String[] actualVals = actualMap.get(key); Assert.assertTrue(Arrays.equals(expectedVals, actualVals)); } } } jmh-1.37/jmh-core/src/test/resources/000077500000000000000000000000001446271450100175125ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/resources/META-INF/000077500000000000000000000000001446271450100206525ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/resources/META-INF/CompilerHints000066400000000000000000000000411446271450100233500ustar00rootroot00000000000000dontinline,some/dummy/class.benchjmh-1.37/jmh-core/src/test/resources/org/000077500000000000000000000000001446271450100203015ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/resources/org/openjdk/000077500000000000000000000000001446271450100217335ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/000077500000000000000000000000001446271450100225115ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/000077500000000000000000000000001446271450100242125ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/000077500000000000000000000000001446271450100255025ustar00rootroot00000000000000jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.root000066400000000000000000000043451446271450100320150ustar00rootroot00000000000000"Benchmark","Mode","Threads","Samples","Score","Score Error (99.9%)","Unit","Param: param0","Param: param1","Param: param2","Param: param3","Param: param4" "benchmark_0","thrpt",80,14,528.857143,278.141953,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_0:secondary1","thrpt",80,14,549.714286,320.227488,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_0:secondary2","thrpt",80,14,615.500000,319.209585,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_0:secondary3","thrpt",80,5,246.000000,847.566004,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_1","thrpt",900,1,439.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_1:secondary1","thrpt",900,1,953.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_1:secondary2","thrpt",900,1,367.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2","thrpt",466,9,545.000000,553.336699,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2:secondary1","thrpt",466,9,434.444444,465.182504,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2:secondary2","thrpt",466,9,470.333333,502.273041,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2:secondary3","thrpt",466,5,574.400000,969.535252,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3","thrpt",968,14,417.571429,362.813967,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3:secondary1","thrpt",968,14,672.214286,287.982211,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3:secondary2","thrpt",968,14,560.142857,289.799961,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3:secondary3","thrpt",968,6,432.833333,1036.758184,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4","thrpt",739,1,956.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4:secondary1","thrpt",739,1,688.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4:secondary2","thrpt",739,1,237.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4:secondary3","thrpt",739,1,599.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4"""jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.ru000066400000000000000000000044431446271450100314570ustar00rootroot00000000000000"Benchmark","Mode","Threads","Samples","Score","Score Error (99,9%)","Unit","Param: param0","Param: param1","Param: param2","Param: param3","Param: param4" "benchmark_0","thrpt",80,14,"528,857143","278,141953","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_0:secondary1","thrpt",80,14,"549,714286","320,227488","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_0:secondary2","thrpt",80,14,"615,500000","319,209585","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_0:secondary3","thrpt",80,5,"246,000000","847,566004","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_1","thrpt",900,1,"439,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_1:secondary1","thrpt",900,1,"953,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_1:secondary2","thrpt",900,1,"367,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2","thrpt",466,9,"545,000000","553,336699","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2:secondary1","thrpt",466,9,"434,444444","465,182504","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2:secondary2","thrpt",466,9,"470,333333","502,273041","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2:secondary3","thrpt",466,5,"574,400000","969,535252","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3","thrpt",968,14,"417,571429","362,813967","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3:secondary1","thrpt",968,14,"672,214286","287,982211","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3:secondary2","thrpt",968,14,"560,142857","289,799961","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3:secondary3","thrpt",968,6,"432,833333","1036,758184","ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4","thrpt",739,1,"956,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4:secondary1","thrpt",739,1,"688,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4:secondary2","thrpt",739,1,"237,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4:secondary3","thrpt",739,1,"599,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4"""jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.us000066400000000000000000000043451446271450100314610ustar00rootroot00000000000000"Benchmark","Mode","Threads","Samples","Score","Score Error (99.9%)","Unit","Param: param0","Param: param1","Param: param2","Param: param3","Param: param4" "benchmark_0","thrpt",80,14,528.857143,278.141953,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_0:secondary1","thrpt",80,14,549.714286,320.227488,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_0:secondary2","thrpt",80,14,615.500000,319.209585,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_0:secondary3","thrpt",80,5,246.000000,847.566004,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_1","thrpt",900,1,439.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_1:secondary1","thrpt",900,1,953.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_1:secondary2","thrpt",900,1,367.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2","thrpt",466,9,545.000000,553.336699,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2:secondary1","thrpt",466,9,434.444444,465.182504,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2:secondary2","thrpt",466,9,470.333333,502.273041,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_2:secondary3","thrpt",466,5,574.400000,969.535252,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3","thrpt",968,14,417.571429,362.813967,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3:secondary1","thrpt",968,14,672.214286,287.982211,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3:secondary2","thrpt",968,14,560.142857,289.799961,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_3:secondary3","thrpt",968,6,432.833333,1036.758184,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4","thrpt",739,1,956.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4:secondary1","thrpt",739,1,688.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4:secondary2","thrpt",739,1,237.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" "benchmark_4:secondary3","thrpt",739,1,599.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4"""jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json000066400000000000000000000574561446271450100312240ustar00rootroot00000000000000[ { "jmhVersion" : "1.18", "benchmark" : "benchmark_0", "mode" : "thrpt", "threads" : 80, "forks" : 828, "jvm" : "javadummy", "jvmArgs" : [ ], "jdkVersion" : "1.8-dummy", "vmName" : "DummyVM", "vmVersion" : "4711", "warmupIterations" : 84, "warmupTime" : "375 s", "warmupBatchSize" : 1, "measurementIterations" : 802, "measurementTime" : "501 s", "measurementBatchSize" : 1, "params" : { "param0" : "value0", "param1" : "[value1]", "param2" : "{value2}", "param3" : "'value3'", "param4" : "\"value4\"" }, "primaryMetric" : { "score" : 528.8571428571429, "scoreError" : 278.1419529743147, "scoreConfidence" : [ 250.7151898828282, 806.9990958314576 ], "scorePercentiles" : { "0.0" : 87.0, "50.0" : 567.5, "90.0" : 884.0, "95.0" : 942.0, "99.0" : 942.0, "99.9" : 942.0, "99.99" : 942.0, "99.999" : 942.0, "99.9999" : 942.0, "100.0" : 942.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 942.0, 384.0 ], [ 351.0, 781.0 ], [ 397.0, 555.0 ], [ 582.0, 580.0 ], [ 644.0 ], [ 655.0, 87.0, 499.0 ], [ 121.0, 826.0 ] ] }, "secondaryMetrics" : { "secondary1" : { "score" : 549.7142857142857, "scoreError" : 320.2274881224688, "scoreConfidence" : [ 229.48679759181687, 869.9417738367545 ], "scorePercentiles" : { "0.0" : 54.0, "50.0" : 527.0, "90.0" : 935.0, "95.0" : 952.0, "99.0" : 952.0, "99.9" : 952.0, "99.99" : 952.0, "99.999" : 952.0, "99.9999" : 952.0, "100.0" : 952.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 390.0, 787.0 ], [ 792.0, 425.0 ], [ 501.0, 952.0 ], [ 99.0, 412.0 ], [ 54.0 ], [ 594.0, 553.0, 370.0 ], [ 918.0, 849.0 ] ] }, "secondary2" : { "score" : 615.5, "scoreError" : 319.2095847883776, "scoreConfidence" : [ 296.2904152116224, 934.7095847883776 ], "scorePercentiles" : { "0.0" : 56.0, "50.0" : 724.5, "90.0" : 967.5, "95.0" : 992.0, "99.0" : 992.0, "99.9" : 992.0, "99.99" : 992.0, "99.999" : 992.0, "99.9999" : 992.0, "100.0" : 992.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 806.0, 303.0 ], [ 316.0, 943.0 ], [ 825.0, 831.0 ], [ 758.0, 691.0 ], [ 508.0 ], [ 497.0, 318.0, 773.0 ], [ 56.0, 992.0 ] ] }, "secondary3" : { "score" : 246.0, "scoreError" : 847.5660039814766, "scoreConfidence" : [ -601.5660039814766, 1093.5660039814766 ], "scorePercentiles" : { "0.0" : 12.0, "50.0" : 241.0, "90.0" : 532.0, "95.0" : 532.0, "99.0" : 532.0, "99.9" : 532.0, "99.99" : 532.0, "99.999" : 532.0, "99.9999" : 532.0, "100.0" : 532.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 241.0 ], [ 55.0 ], [ ], [ ], [ ], [ 390.0, 12.0 ], [ 532.0 ] ] } } }, { "jmhVersion" : "1.18", "benchmark" : "benchmark_1", "mode" : "thrpt", "threads" : 900, "forks" : 364, "jvm" : "javadummy", "jvmArgs" : [ ], "jdkVersion" : "1.8-dummy", "vmName" : "DummyVM", "vmVersion" : "4711", "warmupIterations" : 544, "warmupTime" : "409 s", "warmupBatchSize" : 1, "measurementIterations" : 55, "measurementTime" : "398 s", "measurementBatchSize" : 1, "params" : { "param0" : "value0", "param1" : "[value1]", "param2" : "{value2}", "param3" : "'value3'", "param4" : "\"value4\"" }, "primaryMetric" : { "score" : 439.0, "scoreError" : "NaN", "scoreConfidence" : [ "NaN", "NaN" ], "scorePercentiles" : { "0.0" : 439.0, "50.0" : 439.0, "90.0" : 439.0, "95.0" : 439.0, "99.0" : 439.0, "99.9" : 439.0, "99.99" : 439.0, "99.999" : 439.0, "99.9999" : 439.0, "100.0" : 439.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 439.0 ] ] }, "secondaryMetrics" : { "secondary1" : { "score" : 953.0, "scoreError" : "NaN", "scoreConfidence" : [ "NaN", "NaN" ], "scorePercentiles" : { "0.0" : 953.0, "50.0" : 953.0, "90.0" : 953.0, "95.0" : 953.0, "99.0" : 953.0, "99.9" : 953.0, "99.99" : 953.0, "99.999" : 953.0, "99.9999" : 953.0, "100.0" : 953.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 953.0 ] ] }, "secondary2" : { "score" : 367.0, "scoreError" : "NaN", "scoreConfidence" : [ "NaN", "NaN" ], "scorePercentiles" : { "0.0" : 367.0, "50.0" : 367.0, "90.0" : 367.0, "95.0" : 367.0, "99.0" : 367.0, "99.9" : 367.0, "99.99" : 367.0, "99.999" : 367.0, "99.9999" : 367.0, "100.0" : 367.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 367.0 ] ] } } }, { "jmhVersion" : "1.18", "benchmark" : "benchmark_2", "mode" : "thrpt", "threads" : 466, "forks" : 677, "jvm" : "javadummy", "jvmArgs" : [ ], "jdkVersion" : "1.8-dummy", "vmName" : "DummyVM", "vmVersion" : "4711", "warmupIterations" : 384, "warmupTime" : "105 s", "warmupBatchSize" : 1, "measurementIterations" : 461, "measurementTime" : "96 s", "measurementBatchSize" : 1, "params" : { "param0" : "value0", "param1" : "[value1]", "param2" : "{value2}", "param3" : "'value3'", "param4" : "\"value4\"" }, "primaryMetric" : { "score" : 545.0, "scoreError" : 553.3366994253071, "scoreConfidence" : [ -8.336699425307074, 1098.336699425307 ], "scorePercentiles" : { "0.0" : 100.0, "50.0" : 497.0, "90.0" : 986.0, "95.0" : 986.0, "99.0" : 986.0, "99.9" : 986.0, "99.99" : 986.0, "99.999" : 986.0, "99.9999" : 986.0, "100.0" : 986.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 749.0, 105.0, 100.0, 863.0 ], [ 836.0, 497.0, 390.0, 379.0, 986.0 ] ] }, "secondaryMetrics" : { "secondary1" : { "score" : 434.44444444444446, "scoreError" : 465.1825044536822, "scoreConfidence" : [ -30.738060009237756, 899.6269488981267 ], "scorePercentiles" : { "0.0" : 88.0, "50.0" : 499.0, "90.0" : 823.0, "95.0" : 823.0, "99.0" : 823.0, "99.9" : 823.0, "99.99" : 823.0, "99.999" : 823.0, "99.9999" : 823.0, "100.0" : 823.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 170.0, 532.0, 586.0, 104.0 ], [ 775.0, 88.0, 823.0, 499.0, 333.0 ] ] }, "secondary2" : { "score" : 470.3333333333333, "scoreError" : 502.27304118350804, "scoreConfidence" : [ -31.939707850174727, 972.6063745168414 ], "scorePercentiles" : { "0.0" : 151.0, "50.0" : 339.0, "90.0" : 974.0, "95.0" : 974.0, "99.0" : 974.0, "99.9" : 974.0, "99.99" : 974.0, "99.999" : 974.0, "99.9999" : 974.0, "100.0" : 974.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 574.0, 246.0, 151.0, 665.0 ], [ 173.0, 974.0, 291.0, 339.0, 820.0 ] ] }, "secondary3" : { "score" : 574.4, "scoreError" : 969.5352515511869, "scoreConfidence" : [ -395.1352515511869, 1543.9352515511869 ], "scorePercentiles" : { "0.0" : 351.0, "50.0" : 428.0, "90.0" : 871.0, "95.0" : 871.0, "99.0" : 871.0, "99.9" : 871.0, "99.99" : 871.0, "99.999" : 871.0, "99.9999" : 871.0, "100.0" : 871.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 351.0, 428.0 ], [ 871.0, 397.0, 825.0 ] ] } } }, { "jmhVersion" : "1.18", "benchmark" : "benchmark_3", "mode" : "thrpt", "threads" : 968, "forks" : 581, "jvm" : "javadummy", "jvmArgs" : [ ], "jdkVersion" : "1.8-dummy", "vmName" : "DummyVM", "vmVersion" : "4711", "warmupIterations" : 628, "warmupTime" : "207 s", "warmupBatchSize" : 1, "measurementIterations" : 857, "measurementTime" : "438 s", "measurementBatchSize" : 1, "params" : { "param0" : "value0", "param1" : "[value1]", "param2" : "{value2}", "param3" : "'value3'", "param4" : "\"value4\"" }, "primaryMetric" : { "score" : 417.57142857142856, "scoreError" : 362.81396705929166, "scoreConfidence" : [ 54.7574615121369, 780.3853956307203 ], "scorePercentiles" : { "0.0" : 21.0, "50.0" : 396.5, "90.0" : 890.0, "95.0" : 979.0, "99.0" : 979.0, "99.9" : 979.0, "99.99" : 979.0, "99.999" : 979.0, "99.9999" : 979.0, "100.0" : 979.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 145.0, 502.0, 686.0, 291.0, 665.0, 120.0, 63.0, 570.0 ], [ 801.0 ], [ 731.0, 21.0 ], [ 147.0, 125.0, 979.0 ] ] }, "secondaryMetrics" : { "secondary1" : { "score" : 672.2142857142857, "scoreError" : 287.98221103408406, "scoreConfidence" : [ 384.2320746802016, 960.1964967483698 ], "scorePercentiles" : { "0.0" : 232.0, "50.0" : 686.0, "90.0" : 975.0, "95.0" : 983.0, "99.0" : 983.0, "99.9" : 983.0, "99.99" : 983.0, "99.999" : 983.0, "99.9999" : 983.0, "100.0" : 983.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 454.0, 626.0, 584.0, 858.0, 967.0, 814.0, 587.0, 423.0 ], [ 746.0 ], [ 888.0, 284.0 ], [ 965.0, 983.0, 232.0 ] ] }, "secondary2" : { "score" : 560.1428571428571, "scoreError" : 289.79996145153024, "scoreConfidence" : [ 270.3428956913269, 849.9428185943873 ], "scorePercentiles" : { "0.0" : 114.0, "50.0" : 559.5, "90.0" : 866.5, "95.0" : 870.0, "99.0" : 870.0, "99.9" : 870.0, "99.99" : 870.0, "99.999" : 870.0, "99.9999" : 870.0, "100.0" : 870.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 114.0, 166.0, 559.0, 560.0, 341.0, 765.0, 353.0, 522.0 ], [ 779.0 ], [ 870.0, 848.0 ], [ 863.0, 392.0, 710.0 ] ] }, "secondary3" : { "score" : 432.8333333333333, "scoreError" : 1036.7581839145614, "scoreConfidence" : [ -603.9248505812282, 1469.5915172478947 ], "scorePercentiles" : { "0.0" : 10.0, "50.0" : 381.0, "90.0" : 952.0, "95.0" : 952.0, "99.0" : 952.0, "99.9" : 952.0, "99.99" : 952.0, "99.999" : 952.0, "99.9999" : 952.0, "100.0" : 952.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 952.0, 10.0, 99.0 ], [ 412.0 ], [ 350.0, 774.0 ], [ ] ] } } }, { "jmhVersion" : "1.18", "benchmark" : "benchmark_4", "mode" : "thrpt", "threads" : 739, "forks" : 670, "jvm" : "javadummy", "jvmArgs" : [ ], "jdkVersion" : "1.8-dummy", "vmName" : "DummyVM", "vmVersion" : "4711", "warmupIterations" : 997, "warmupTime" : "651 s", "warmupBatchSize" : 1, "measurementIterations" : 16, "measurementTime" : "763 s", "measurementBatchSize" : 1, "params" : { "param0" : "value0", "param1" : "[value1]", "param2" : "{value2}", "param3" : "'value3'", "param4" : "\"value4\"" }, "primaryMetric" : { "score" : 956.0, "scoreError" : "NaN", "scoreConfidence" : [ "NaN", "NaN" ], "scorePercentiles" : { "0.0" : 956.0, "50.0" : 956.0, "90.0" : 956.0, "95.0" : 956.0, "99.0" : 956.0, "99.9" : 956.0, "99.99" : 956.0, "99.999" : 956.0, "99.9999" : 956.0, "100.0" : 956.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 956.0 ] ] }, "secondaryMetrics" : { "secondary1" : { "score" : 688.0, "scoreError" : "NaN", "scoreConfidence" : [ "NaN", "NaN" ], "scorePercentiles" : { "0.0" : 688.0, "50.0" : 688.0, "90.0" : 688.0, "95.0" : 688.0, "99.0" : 688.0, "99.9" : 688.0, "99.99" : 688.0, "99.999" : 688.0, "99.9999" : 688.0, "100.0" : 688.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 688.0 ] ] }, "secondary2" : { "score" : 237.0, "scoreError" : "NaN", "scoreConfidence" : [ "NaN", "NaN" ], "scorePercentiles" : { "0.0" : 237.0, "50.0" : 237.0, "90.0" : 237.0, "95.0" : 237.0, "99.0" : 237.0, "99.9" : 237.0, "99.99" : 237.0, "99.999" : 237.0, "99.9999" : 237.0, "100.0" : 237.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 237.0 ] ] }, "secondary3" : { "score" : 599.0, "scoreError" : "NaN", "scoreConfidence" : [ "NaN", "NaN" ], "scorePercentiles" : { "0.0" : 599.0, "50.0" : 599.0, "90.0" : 599.0, "95.0" : 599.0, "99.0" : 599.0, "99.9" : 599.0, "99.99" : 599.0, "99.999" : 599.0, "99.9999" : 599.0, "100.0" : 599.0 }, "scoreUnit" : "ops/ms", "rawData" : [ [ 599.0 ] ] } } } ] jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.root000066400000000000000000000070171446271450100323360ustar00rootroot00000000000000\begin{tabular}{r|l|l|l|l|l|rl} \multicolumn{1}{c|}{\texttt{Benchmark}} & \texttt{param0} & \texttt{param1} & \texttt{param2} & \texttt{param3} & \texttt{param4} & \multicolumn{2}{c}{\texttt{Score, ops/ms}} \\ \hline \texttt{benchmark\_0} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{528.857} & \scriptsize $\pm$ \texttt{278.142} \\ \texttt{benchmark\_0:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{549.714} & \scriptsize $\pm$ \texttt{320.227} \\ \texttt{benchmark\_0:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{615.500} & \scriptsize $\pm$ \texttt{319.210} \\ \texttt{benchmark\_0:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{246.000} & \scriptsize $\pm$ \texttt{847.566} \\ \texttt{benchmark\_1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{439.000} & \\ \texttt{benchmark\_1:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{953.000} & \\ \texttt{benchmark\_1:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{367.000} & \\ \texttt{benchmark\_2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{545.000} & \scriptsize $\pm$ \texttt{553.337} \\ \texttt{benchmark\_2:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{434.444} & \scriptsize $\pm$ \texttt{465.183} \\ \texttt{benchmark\_2:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{470.333} & \scriptsize $\pm$ \texttt{502.273} \\ \texttt{benchmark\_2:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{574.400} & \scriptsize $\pm$ \texttt{969.535} \\ \texttt{benchmark\_3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{417.571} & \scriptsize $\pm$ \texttt{362.814} \\ \texttt{benchmark\_3:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{672.214} & \scriptsize $\pm$ \texttt{287.982} \\ \texttt{benchmark\_3:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{560.143} & \scriptsize $\pm$ \texttt{289.800} \\ \texttt{benchmark\_3:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{432.833} & \scriptsize $\pm$ \texttt{1036.758} \\ \texttt{benchmark\_4} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{956.000} & \\ \texttt{benchmark\_4:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{688.000} & \\ \texttt{benchmark\_4:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{237.000} & \\ \texttt{benchmark\_4:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{599.000} & \\ \end{tabular}jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.ru000066400000000000000000000070171446271450100320010ustar00rootroot00000000000000\begin{tabular}{r|l|l|l|l|l|rl} \multicolumn{1}{c|}{\texttt{Benchmark}} & \texttt{param0} & \texttt{param1} & \texttt{param2} & \texttt{param3} & \texttt{param4} & \multicolumn{2}{c}{\texttt{Score, ops/ms}} \\ \hline \texttt{benchmark\_0} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{528,857} & \scriptsize $\pm$ \texttt{278,142} \\ \texttt{benchmark\_0:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{549,714} & \scriptsize $\pm$ \texttt{320,227} \\ \texttt{benchmark\_0:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{615,500} & \scriptsize $\pm$ \texttt{319,210} \\ \texttt{benchmark\_0:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{246,000} & \scriptsize $\pm$ \texttt{847,566} \\ \texttt{benchmark\_1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{439,000} & \\ \texttt{benchmark\_1:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{953,000} & \\ \texttt{benchmark\_1:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{367,000} & \\ \texttt{benchmark\_2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{545,000} & \scriptsize $\pm$ \texttt{553,337} \\ \texttt{benchmark\_2:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{434,444} & \scriptsize $\pm$ \texttt{465,183} \\ \texttt{benchmark\_2:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{470,333} & \scriptsize $\pm$ \texttt{502,273} \\ \texttt{benchmark\_2:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{574,400} & \scriptsize $\pm$ \texttt{969,535} \\ \texttt{benchmark\_3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{417,571} & \scriptsize $\pm$ \texttt{362,814} \\ \texttt{benchmark\_3:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{672,214} & \scriptsize $\pm$ \texttt{287,982} \\ \texttt{benchmark\_3:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{560,143} & \scriptsize $\pm$ \texttt{289,800} \\ \texttt{benchmark\_3:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{432,833} & \scriptsize $\pm$ \texttt{1036,758} \\ \texttt{benchmark\_4} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{956,000} & \\ \texttt{benchmark\_4:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{688,000} & \\ \texttt{benchmark\_4:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{237,000} & \\ \texttt{benchmark\_4:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{599,000} & \\ \end{tabular}jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.us000066400000000000000000000070171446271450100320020ustar00rootroot00000000000000\begin{tabular}{r|l|l|l|l|l|rl} \multicolumn{1}{c|}{\texttt{Benchmark}} & \texttt{param0} & \texttt{param1} & \texttt{param2} & \texttt{param3} & \texttt{param4} & \multicolumn{2}{c}{\texttt{Score, ops/ms}} \\ \hline \texttt{benchmark\_0} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{528.857} & \scriptsize $\pm$ \texttt{278.142} \\ \texttt{benchmark\_0:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{549.714} & \scriptsize $\pm$ \texttt{320.227} \\ \texttt{benchmark\_0:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{615.500} & \scriptsize $\pm$ \texttt{319.210} \\ \texttt{benchmark\_0:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{246.000} & \scriptsize $\pm$ \texttt{847.566} \\ \texttt{benchmark\_1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{439.000} & \\ \texttt{benchmark\_1:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{953.000} & \\ \texttt{benchmark\_1:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{367.000} & \\ \texttt{benchmark\_2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{545.000} & \scriptsize $\pm$ \texttt{553.337} \\ \texttt{benchmark\_2:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{434.444} & \scriptsize $\pm$ \texttt{465.183} \\ \texttt{benchmark\_2:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{470.333} & \scriptsize $\pm$ \texttt{502.273} \\ \texttt{benchmark\_2:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{574.400} & \scriptsize $\pm$ \texttt{969.535} \\ \texttt{benchmark\_3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{417.571} & \scriptsize $\pm$ \texttt{362.814} \\ \texttt{benchmark\_3:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{672.214} & \scriptsize $\pm$ \texttt{287.982} \\ \texttt{benchmark\_3:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{560.143} & \scriptsize $\pm$ \texttt{289.800} \\ \texttt{benchmark\_3:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{432.833} & \scriptsize $\pm$ \texttt{1036.758} \\ \texttt{benchmark\_4} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{956.000} & \\ \texttt{benchmark\_4:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{688.000} & \\ \texttt{benchmark\_4:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{237.000} & \\ \texttt{benchmark\_4:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{599.000} & \\ \end{tabular}jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.root000066400000000000000000000043451446271450100322000ustar00rootroot00000000000000"Benchmark";"Mode";"Threads";"Samples";"Score";"Score Error (99.9%)";"Unit";"Param: param0";"Param: param1";"Param: param2";"Param: param3";"Param: param4" "benchmark_0";"thrpt";80;14;528.857143;278.141953;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_0:secondary1";"thrpt";80;14;549.714286;320.227488;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_0:secondary2";"thrpt";80;14;615.500000;319.209585;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_0:secondary3";"thrpt";80;5;246.000000;847.566004;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_1";"thrpt";900;1;439.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_1:secondary1";"thrpt";900;1;953.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_1:secondary2";"thrpt";900;1;367.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2";"thrpt";466;9;545.000000;553.336699;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2:secondary1";"thrpt";466;9;434.444444;465.182504;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2:secondary2";"thrpt";466;9;470.333333;502.273041;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2:secondary3";"thrpt";466;5;574.400000;969.535252;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3";"thrpt";968;14;417.571429;362.813967;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3:secondary1";"thrpt";968;14;672.214286;287.982211;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3:secondary2";"thrpt";968;14;560.142857;289.799961;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3:secondary3";"thrpt";968;6;432.833333;1036.758184;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4";"thrpt";739;1;956.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4:secondary1";"thrpt";739;1;688.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4:secondary2";"thrpt";739;1;237.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4:secondary3";"thrpt";739;1;599.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4"""jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.ru000066400000000000000000000043451446271450100316430ustar00rootroot00000000000000"Benchmark";"Mode";"Threads";"Samples";"Score";"Score Error (99,9%)";"Unit";"Param: param0";"Param: param1";"Param: param2";"Param: param3";"Param: param4" "benchmark_0";"thrpt";80;14;528,857143;278,141953;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_0:secondary1";"thrpt";80;14;549,714286;320,227488;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_0:secondary2";"thrpt";80;14;615,500000;319,209585;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_0:secondary3";"thrpt";80;5;246,000000;847,566004;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_1";"thrpt";900;1;439,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_1:secondary1";"thrpt";900;1;953,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_1:secondary2";"thrpt";900;1;367,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2";"thrpt";466;9;545,000000;553,336699;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2:secondary1";"thrpt";466;9;434,444444;465,182504;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2:secondary2";"thrpt";466;9;470,333333;502,273041;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2:secondary3";"thrpt";466;5;574,400000;969,535252;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3";"thrpt";968;14;417,571429;362,813967;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3:secondary1";"thrpt";968;14;672,214286;287,982211;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3:secondary2";"thrpt";968;14;560,142857;289,799961;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3:secondary3";"thrpt";968;6;432,833333;1036,758184;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4";"thrpt";739;1;956,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4:secondary1";"thrpt";739;1;688,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4:secondary2";"thrpt";739;1;237,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4:secondary3";"thrpt";739;1;599,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4"""jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.us000066400000000000000000000043451446271450100316440ustar00rootroot00000000000000"Benchmark";"Mode";"Threads";"Samples";"Score";"Score Error (99.9%)";"Unit";"Param: param0";"Param: param1";"Param: param2";"Param: param3";"Param: param4" "benchmark_0";"thrpt";80;14;528.857143;278.141953;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_0:secondary1";"thrpt";80;14;549.714286;320.227488;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_0:secondary2";"thrpt";80;14;615.500000;319.209585;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_0:secondary3";"thrpt";80;5;246.000000;847.566004;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_1";"thrpt";900;1;439.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_1:secondary1";"thrpt";900;1;953.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_1:secondary2";"thrpt";900;1;367.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2";"thrpt";466;9;545.000000;553.336699;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2:secondary1";"thrpt";466;9;434.444444;465.182504;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2:secondary2";"thrpt";466;9;470.333333;502.273041;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_2:secondary3";"thrpt";466;5;574.400000;969.535252;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3";"thrpt";968;14;417.571429;362.813967;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3:secondary1";"thrpt";968;14;672.214286;287.982211;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3:secondary2";"thrpt";968;14;560.142857;289.799961;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_3:secondary3";"thrpt";968;6;432.833333;1036.758184;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4";"thrpt";739;1;956.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4:secondary1";"thrpt";739;1;688.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4:secondary2";"thrpt";739;1;237.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" "benchmark_4:secondary3";"thrpt";739;1;599.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4"""jmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.root000066400000000000000000000043371446271450100322070ustar00rootroot00000000000000Benchmark (param0) (param1) (param2) (param3) (param4) Mode Cnt Score Error Units benchmark_0 value0 [value1] {value2} 'value3' "value4" thrpt 14 528.857 ± 278.142 ops/ms benchmark_0:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 549.714 ± 320.227 ops/ms benchmark_0:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 615.500 ± 319.210 ops/ms benchmark_0:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 246.000 ± 847.566 ops/ms benchmark_1 value0 [value1] {value2} 'value3' "value4" thrpt 439.000 ops/ms benchmark_1:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 953.000 ops/ms benchmark_1:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 367.000 ops/ms benchmark_2 value0 [value1] {value2} 'value3' "value4" thrpt 9 545.000 ± 553.337 ops/ms benchmark_2:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 9 434.444 ± 465.183 ops/ms benchmark_2:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 9 470.333 ± 502.273 ops/ms benchmark_2:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 574.400 ± 969.535 ops/ms benchmark_3 value0 [value1] {value2} 'value3' "value4" thrpt 14 417.571 ± 362.814 ops/ms benchmark_3:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 672.214 ± 287.982 ops/ms benchmark_3:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 560.143 ± 289.800 ops/ms benchmark_3:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 6 432.833 ± 1036.758 ops/ms benchmark_4 value0 [value1] {value2} 'value3' "value4" thrpt 956.000 ops/ms benchmark_4:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 688.000 ops/ms benchmark_4:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 237.000 ops/ms benchmark_4:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 599.000 ops/msjmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.ru000066400000000000000000000043371446271450100316520ustar00rootroot00000000000000Benchmark (param0) (param1) (param2) (param3) (param4) Mode Cnt Score Error Units benchmark_0 value0 [value1] {value2} 'value3' "value4" thrpt 14 528,857 ± 278,142 ops/ms benchmark_0:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 549,714 ± 320,227 ops/ms benchmark_0:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 615,500 ± 319,210 ops/ms benchmark_0:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 246,000 ± 847,566 ops/ms benchmark_1 value0 [value1] {value2} 'value3' "value4" thrpt 439,000 ops/ms benchmark_1:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 953,000 ops/ms benchmark_1:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 367,000 ops/ms benchmark_2 value0 [value1] {value2} 'value3' "value4" thrpt 9 545,000 ± 553,337 ops/ms benchmark_2:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 9 434,444 ± 465,183 ops/ms benchmark_2:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 9 470,333 ± 502,273 ops/ms benchmark_2:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 574,400 ± 969,535 ops/ms benchmark_3 value0 [value1] {value2} 'value3' "value4" thrpt 14 417,571 ± 362,814 ops/ms benchmark_3:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 672,214 ± 287,982 ops/ms benchmark_3:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 560,143 ± 289,800 ops/ms benchmark_3:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 6 432,833 ± 1036,758 ops/ms benchmark_4 value0 [value1] {value2} 'value3' "value4" thrpt 956,000 ops/ms benchmark_4:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 688,000 ops/ms benchmark_4:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 237,000 ops/ms benchmark_4:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 599,000 ops/msjmh-1.37/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.us000066400000000000000000000043371446271450100316530ustar00rootroot00000000000000Benchmark (param0) (param1) (param2) (param3) (param4) Mode Cnt Score Error Units benchmark_0 value0 [value1] {value2} 'value3' "value4" thrpt 14 528.857 ± 278.142 ops/ms benchmark_0:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 549.714 ± 320.227 ops/ms benchmark_0:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 615.500 ± 319.210 ops/ms benchmark_0:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 246.000 ± 847.566 ops/ms benchmark_1 value0 [value1] {value2} 'value3' "value4" thrpt 439.000 ops/ms benchmark_1:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 953.000 ops/ms benchmark_1:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 367.000 ops/ms benchmark_2 value0 [value1] {value2} 'value3' "value4" thrpt 9 545.000 ± 553.337 ops/ms benchmark_2:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 9 434.444 ± 465.183 ops/ms benchmark_2:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 9 470.333 ± 502.273 ops/ms benchmark_2:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 574.400 ± 969.535 ops/ms benchmark_3 value0 [value1] {value2} 'value3' "value4" thrpt 14 417.571 ± 362.814 ops/ms benchmark_3:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 672.214 ± 287.982 ops/ms benchmark_3:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 560.143 ± 289.800 ops/ms benchmark_3:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 6 432.833 ± 1036.758 ops/ms benchmark_4 value0 [value1] {value2} 'value3' "value4" thrpt 956.000 ops/ms benchmark_4:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 688.000 ops/ms benchmark_4:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 237.000 ops/ms benchmark_4:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 599.000 ops/msjmh-1.37/jmh-generator-annprocess/000077500000000000000000000000001446271450100171415ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/LICENSE000066400000000000000000000455121446271450100201550ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-generator-annprocess/THIRD-PARTY000066400000000000000000000350611446271450100206400ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-generator-annprocess/pom.xml000066400000000000000000000071611446271450100204630ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent 1.37 JMH Generators: Annotation Processors jmh-generator-annprocess jar JMH benchmark generator, based on annotation processors. org.openjdk.jmh jmh-core ${project.version} UTF-8 org.apache.maven.plugins maven-compiler-plugin -proc:none org.apache.maven.plugins maven-surefire-plugin false com.mycila.maven-license-plugin maven-license-plugin format process-sources
file:///${project.basedir}/../src/license/gpl_cpe/header.txt
true true PHP
jmh-1.37/jmh-generator-annprocess/src/000077500000000000000000000000001446271450100177305ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/000077500000000000000000000000001446271450100206545ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/000077500000000000000000000000001446271450100215755ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/000077500000000000000000000000001446271450100223645ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/000077500000000000000000000000001446271450100240165ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/000077500000000000000000000000001446271450100245745ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/000077500000000000000000000000001446271450100267455ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/BenchmarkProcessor.java000066400000000000000000000053101446271450100334010ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators; import org.openjdk.jmh.generators.annotations.APGeneratorDestinaton; import org.openjdk.jmh.generators.annotations.APGeneratorSource; import org.openjdk.jmh.generators.core.BenchmarkGenerator; import org.openjdk.jmh.generators.core.GeneratorDestination; import org.openjdk.jmh.generators.core.GeneratorSource; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; import javax.lang.model.SourceVersion; import javax.lang.model.element.TypeElement; import java.util.Set; @SupportedAnnotationTypes("org.openjdk.jmh.annotations.*") public class BenchmarkProcessor extends AbstractProcessor { private final BenchmarkGenerator generator = new BenchmarkGenerator(); @Override public SourceVersion getSupportedSourceVersion() { // We may claim to support the latest version, since we are not using // any version-specific extensions. return SourceVersion.latest(); } @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { GeneratorSource source = new APGeneratorSource(roundEnv, processingEnv); GeneratorDestination destination = new APGeneratorDestinaton(roundEnv, processingEnv); if (!roundEnv.processingOver()) { generator.generate(source, destination); } else { generator.complete(source, destination); } return true; } } jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/000077500000000000000000000000001446271450100313025ustar00rootroot00000000000000APClassInfo.java000066400000000000000000000154601446271450100341760ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.annotations; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.FieldInfo; import org.openjdk.jmh.generators.core.MethodInfo; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; class APClassInfo extends APMetadataInfo implements ClassInfo { private final TypeElement el; private final boolean isSpecial; private final TypeMirror mirror; public APClassInfo(ProcessingEnvironment processEnv, TypeElement element) { super(processEnv, element); if (element == null) { throw new IllegalArgumentException("element is null"); } this.el = element; this.isSpecial = false; this.mirror = null; } public APClassInfo(ProcessingEnvironment processEnv, TypeMirror mirror) { super(processEnv, processEnv.getTypeUtils().asElement(mirror)); this.mirror = mirror; this.isSpecial = mirror.getKind() != TypeKind.DECLARED; if (isSpecial) { this.el = null; } else { Element element = processEnv.getTypeUtils().asElement(mirror); this.el = (TypeElement) element; } } @Override public T getAnnotation(Class annClass) { if (isSpecial) return null; return el.getAnnotation(annClass); } @Override public Collection getConstructors() { if (isSpecial) return Collections.emptyList(); Collection mis = new ArrayList<>(); for (ExecutableElement e : ElementFilter.constructorsIn(el.getEnclosedElements())) { mis.add(new APMethodInfo(processEnv, this, e)); } return mis; } @Override public String getName() { if (isSpecial) return mirror.toString(); return el.getSimpleName().toString(); } @Override public String getQualifiedName() { if (isSpecial) return mirror.toString(); return el.getQualifiedName().toString(); } @Override public Collection getFields() { if (isSpecial) return Collections.emptyList(); List ls = new ArrayList<>(); for (VariableElement e : ElementFilter.fieldsIn(el.getEnclosedElements())) { ls.add(new APFieldInfo(processEnv, e)); } return ls; } @Override public Collection getMethods() { if (isSpecial) return Collections.emptyList(); Collection mis = new ArrayList<>(); for (ExecutableElement e : ElementFilter.methodsIn(el.getEnclosedElements())) { mis.add(new APMethodInfo(processEnv, this, e)); } return mis; } @Override public String getPackageName() { if (isSpecial) return ""; Element walk = el; while (walk.getKind() != ElementKind.PACKAGE) { walk = walk.getEnclosingElement(); } return ((PackageElement)walk).getQualifiedName().toString(); } @Override public ClassInfo getSuperClass() { if (isSpecial) return null; TypeMirror superclass = el.getSuperclass(); if (superclass.getKind() == TypeKind.NONE) { return null; } else { TypeElement element = (TypeElement) processEnv.getTypeUtils().asElement(superclass); return new APClassInfo(processEnv, element); } } @Override public ClassInfo getDeclaringClass() { if (isSpecial) return null; Element enclosingElement = el.getEnclosingElement(); if (enclosingElement.getKind() == ElementKind.CLASS) { return new APClassInfo(processEnv, (TypeElement) enclosingElement); } else { return null; } } @Override public boolean isAbstract() { if (isSpecial) return false; return el.getModifiers().contains(Modifier.ABSTRACT); } @Override public boolean isPublic() { if (isSpecial) return true; return el.getModifiers().contains(Modifier.PUBLIC); } @Override public boolean isStrictFP() { if (isSpecial) return false; return el.getModifiers().contains(Modifier.STRICTFP); } @Override public boolean isFinal() { if (isSpecial) return false; return el.getModifiers().contains(Modifier.FINAL); } @Override public boolean isInner() { if (isSpecial) return false; return (getDeclaringClass() != null) && !el.getModifiers().contains(Modifier.STATIC); } @Override public boolean isEnum() { if (isSpecial) return false; return el.getKind() == ElementKind.ENUM; } @Override public Collection getEnumConstants() { Collection result = new ArrayList<>(); for (Element e : el.getEnclosedElements()) { if (e.getKind() == ElementKind.ENUM_CONSTANT) { result.add(e.getSimpleName().toString()); } } return result; } public String toString() { return getQualifiedName(); } } APFieldInfo.java000066400000000000000000000054461446271450100341570ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.annotations; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.FieldInfo; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import java.lang.annotation.Annotation; class APFieldInfo extends APMetadataInfo implements FieldInfo { private final VariableElement ve; public APFieldInfo(ProcessingEnvironment processEnv, VariableElement ve) { super(processEnv, ve); if (ve == null) { throw new IllegalArgumentException("element is null"); } this.ve = ve; } @Override public String getName() { return ve.getSimpleName().toString(); } @Override public ClassInfo getType() { return new APClassInfo(processEnv, ve.asType()); } @Override public boolean isPublic() { return ve.getModifiers().contains(Modifier.PUBLIC); } @Override public boolean isStatic() { return ve.getModifiers().contains(Modifier.STATIC); } @Override public boolean isFinal() { return ve.getModifiers().contains(Modifier.FINAL); } @Override public T getAnnotation(Class annClass) { return ve.getAnnotation(annClass); } @Override public ClassInfo getDeclaringClass() { return new APClassInfo(processEnv, (TypeElement)ve.getEnclosingElement()); } public String toString() { return getType() + " " + getName(); } } APGeneratorDestinaton.java000066400000000000000000000100111446271450100362570ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.annotations; import org.openjdk.jmh.generators.core.GeneratorDestination; import org.openjdk.jmh.generators.core.MetadataInfo; import org.openjdk.jmh.util.Utils; import javax.annotation.processing.Filer; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.element.TypeElement; import javax.tools.Diagnostic; import javax.tools.StandardLocation; import java.io.*; public class APGeneratorDestinaton implements GeneratorDestination { private final ProcessingEnvironment processingEnv; public APGeneratorDestinaton(RoundEnvironment roundEnv, ProcessingEnvironment processingEnv) { this.processingEnv = processingEnv; } @Override public OutputStream newResource(String resourcePath) throws IOException { return processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resourcePath).openOutputStream(); } @Override public InputStream getResource(String resourcePath) throws IOException { return processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resourcePath).openInputStream(); } @Override public Writer newClass(String className, String originatingClassName) throws IOException { Filer filer = processingEnv.getFiler(); if (originatingClassName != null) { TypeElement originatingType = processingEnv.getElementUtils().getTypeElement(originatingClassName); return filer.createSourceFile(className, originatingType).openWriter(); } else { return filer.createSourceFile(className).openWriter(); } } @Override public void printError(String message) { processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, message); } @Override public void printError(String message, MetadataInfo element) { processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, message, ((APMetadataInfo)element).getElement()); } @Override public void printError(String message, Throwable throwable) { printError(message + " " + Utils.throwableToString(throwable)); } @Override public void printWarning(String message) { processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, message); } @Override public void printWarning(String message, MetadataInfo element) { processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, message, ((APMetadataInfo)element).getElement()); } @Override public void printWarning(String message, Throwable throwable) { printWarning(message + " " + Utils.throwableToString(throwable)); } @Override public void printNote(String message) { processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, message); } } APGeneratorSource.java000066400000000000000000000117151446271450100354230ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.annotations; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.GeneratorSource; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; import javax.lang.model.util.ElementFilter; import javax.tools.Diagnostic; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.TreeSet; public class APGeneratorSource implements GeneratorSource { private final RoundEnvironment roundEnv; private final ProcessingEnvironment processingEnv; private Collection classInfos; public APGeneratorSource(RoundEnvironment roundEnv, ProcessingEnvironment processingEnv) { this.roundEnv = roundEnv; this.processingEnv = processingEnv; } @Override public Collection getClasses() { if (classInfos != null) { return classInfos; } Collection discoveredClasses = new TreeSet<>(Comparator.comparing(o -> o.getQualifiedName().toString())); // Need to do a few rollovers to find all classes that have @Benchmark-annotated methods in their // subclasses. This is mostly due to some of the nested classes not discoverable at once, // when we need to discover the enclosing class first. With the potentially non-zero nesting // depth, we need to do a few rounds. Hopefully we will just do a single stride in most // cases. for (Element e : roundEnv.getRootElements()) { if (e.getKind() != ElementKind.CLASS) continue; discoveredClasses.add((TypeElement) e); } int lastSize = 0; while (discoveredClasses.size() > lastSize) { lastSize = discoveredClasses.size(); List newClasses = new ArrayList<>(); for (Element e : discoveredClasses) { try { TypeElement walk = (TypeElement) e; do { newClasses.addAll(ElementFilter.typesIn(walk.getEnclosedElements())); } while ((walk = (TypeElement) processingEnv.getTypeUtils().asElement(walk.getSuperclass())) != null); } catch (Exception t) { // Working around the javac bug: // https://bugs.openjdk.java.net/browse/JDK-8071778 // // JMH ignores these exceptions since they probably consider the classes that do not // have any JMH-related annotations. We can do nothing better than to notify the user, // and bail from traversing a current class. if (t.getClass().getName().endsWith("CompletionFailure")) { processingEnv.getMessager().printMessage(Diagnostic.Kind.MANDATORY_WARNING, "While traversing " + e + ", caught " + t); } else { throw new RuntimeException(t); } } } discoveredClasses.addAll(newClasses); } classInfos = convert(discoveredClasses); return classInfos; } protected Collection convert(Collection els) { List list = new ArrayList<>(); for (TypeElement el : els) { list.add(new APClassInfo(processingEnv, el)); } return list; } @Override public ClassInfo resolveClass(String className) { return new APClassInfo(processingEnv, processingEnv.getElementUtils().getTypeElement(className)); } } APMetadataInfo.java000066400000000000000000000032421446271450100346440ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.annotations; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; class APMetadataInfo { protected final ProcessingEnvironment processEnv; private final Element element; public APMetadataInfo(ProcessingEnvironment processEnv, Element element) { this.processEnv = processEnv; this.element = element; } public Element getElement() { return element; } } APMethodInfo.java000066400000000000000000000074161446271450100343530ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.annotations; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.MethodInfo; import org.openjdk.jmh.generators.core.ParameterInfo; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.VariableElement; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Collection; class APMethodInfo extends APMetadataInfo implements MethodInfo { private final ClassInfo ci; private final ExecutableElement el; public APMethodInfo(ProcessingEnvironment processEnv, ClassInfo ci, ExecutableElement el) { super(processEnv, el); if (ci == null) { throw new IllegalArgumentException("ci is null"); } if (el == null) { throw new IllegalArgumentException("el is null"); } this.ci = ci; this.el = el; } @Override public ClassInfo getDeclaringClass() { return ci; } @Override public String getName() { return el.getSimpleName().toString(); } @Override public String getReturnType() { return el.getReturnType().toString(); } @Override public Collection getParameters() { Collection pis = new ArrayList<>(); for (VariableElement v : el.getParameters()) { pis.add(new APParameterInfo(processEnv, v)); } return pis; } @Override public T getAnnotation(Class annClass) { return el.getAnnotation(annClass); } @Override public boolean isPublic() { return el.getModifiers().contains(Modifier.PUBLIC); } @Override public boolean isAbstract() { return el.getModifiers().contains(Modifier.ABSTRACT); } @Override public boolean isSynchronized() { return el.getModifiers().contains(Modifier.SYNCHRONIZED); } @Override public boolean isStrictFP() { return el.getModifiers().contains(Modifier.STRICTFP); } @Override public boolean isStatic() { return el.getModifiers().contains(Modifier.STATIC); } @Override public String getQualifiedName() { return ci.getQualifiedName() + "." + el.toString(); } @Override public int compareTo(MethodInfo o) { return getQualifiedName().compareTo(o.getQualifiedName()); } public String toString() { return getDeclaringClass() + " " + getName() ; } } APParameterInfo.java000066400000000000000000000037631446271450100350540ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.annotations; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.ParameterInfo; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.VariableElement; class APParameterInfo extends APMetadataInfo implements ParameterInfo { private final VariableElement ve; public APParameterInfo(ProcessingEnvironment processEnv, VariableElement ve) { super(processEnv, ve); if (ve == null) { throw new IllegalArgumentException("element is null"); } this.ve = ve; } @Override public ClassInfo getType() { return new APClassInfo(processEnv, ve.asType()); } public String toString() { return getType() + " " + ve.getSimpleName(); } } jmh-1.37/jmh-generator-annprocess/src/main/resources/000077500000000000000000000000001446271450100226665ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/resources/LICENSE000066400000000000000000000455121446271450100237020ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-generator-annprocess/src/main/resources/META-INF/000077500000000000000000000000001446271450100240265ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/resources/META-INF/gradle/000077500000000000000000000000001446271450100252645ustar00rootroot00000000000000incremental.annotation.processors000066400000000000000000000000701446271450100340000ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/resources/META-INF/gradleorg.openjdk.jmh.generators.BenchmarkProcessor,ISOLATING jmh-1.37/jmh-generator-annprocess/src/main/resources/META-INF/services/000077500000000000000000000000001446271450100256515ustar00rootroot00000000000000javax.annotation.processing.Processor000066400000000000000000000024061446271450100351320ustar00rootroot00000000000000jmh-1.37/jmh-generator-annprocess/src/main/resources/META-INF/services# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. # org.openjdk.jmh.generators.BenchmarkProcessor jmh-1.37/jmh-generator-annprocess/src/main/resources/THIRD-PARTY000066400000000000000000000350611446271450100243650ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-generator-asm/000077500000000000000000000000001446271450100155465ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/LICENSE000066400000000000000000000455121446271450100165620ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-generator-asm/THIRD-PARTY000066400000000000000000000350611446271450100172450ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-generator-asm/pom.xml000066400000000000000000000076451446271450100170770ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent 1.37 JMH Generators: ASM jmh-generator-asm jar JMH benchmark generator, based on ASM bytecode manipulation. org.openjdk.jmh jmh-core ${project.version} org.openjdk.jmh jmh-generator-reflection ${project.version} org.ow2.asm asm UTF-8 org.apache.maven.plugins maven-compiler-plugin -proc:none org.apache.maven.plugins maven-surefire-plugin false com.mycila.maven-license-plugin maven-license-plugin format process-sources
file:///${project.basedir}/../src/license/gpl_cpe/header.txt
true true PHP
jmh-1.37/jmh-generator-asm/src/000077500000000000000000000000001446271450100163355ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/src/main/000077500000000000000000000000001446271450100172615ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/src/main/java/000077500000000000000000000000001446271450100202025ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/src/main/java/org/000077500000000000000000000000001446271450100207715ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/000077500000000000000000000000001446271450100224235ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/jmh/000077500000000000000000000000001446271450100232015ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/000077500000000000000000000000001446271450100253525ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/000077500000000000000000000000001446271450100261325ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java000066400000000000000000000174611446271450100312300ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.asm; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.FieldInfo; import org.openjdk.jmh.generators.core.MethodInfo; import java.lang.annotation.Annotation; import java.lang.reflect.Proxy; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; class ASMClassInfo extends ClassVisitor implements ClassInfo { private String idName; private String packageName; private String qualifiedName; private String name; private int access; private final List methods; private final List constructors; private final List fields; private final Map annotations = new HashMap<>(); private final ClassInfoRepo classInfos; private String superName; private String declaringClass; private boolean isInner; private String origQualifiedName; public ASMClassInfo(ClassInfoRepo classInfos) { super(Opcodes.ASM5); this.classInfos = classInfos; this.methods = new ArrayList<>(); this.constructors = new ArrayList<>(); this.fields = new ArrayList<>(); } public String getIdName() { return idName; } @Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { super.visit(version, access, name, signature, superName, interfaces); this.superName = superName; this.idName = name; this.access = access; this.qualifiedName = name.replace("/", "."); int dotIndex = qualifiedName.lastIndexOf("."); if (dotIndex != -1) { packageName = qualifiedName.substring(0, dotIndex); } else { packageName = ""; } this.origQualifiedName = qualifiedName; this.qualifiedName = qualifiedName.replace('$', '.'); dotIndex = qualifiedName.lastIndexOf("."); if (dotIndex != -1) { this.name = qualifiedName.substring(dotIndex + 1); } else { this.name = qualifiedName; } } @Override public T getAnnotation(Class annClass) { AnnotationInvocationHandler handler = annotations.get(annClass.getCanonicalName()); if (handler == null) { return null; } else { return (T) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[]{annClass}, handler); } } @Override public AnnotationVisitor visitAnnotation(final String desc, boolean visible) { String className = Type.getType(desc).getClassName(); AnnotationInvocationHandler annHandler = new AnnotationInvocationHandler(className, super.visitAnnotation(desc, visible)); annotations.put(className, annHandler); return annHandler; } @Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { ClassInfo type = classInfos.get(Type.getType(desc).getClassName()); FieldVisitor fv = super.visitField(access, name, desc, signature, value); ASMFieldInfo fi = new ASMFieldInfo(fv, this, access, name, type); fields.add(fi); return fi; } @Override public MethodVisitor visitMethod(int access, final String methodName, String methodDesc, String signature, String[] exceptions) { ASMMethodInfo mi = new ASMMethodInfo(super.visitMethod(access, methodName, methodDesc, signature, exceptions), classInfos, this, access, methodName, methodDesc, signature); if (methodName.equals("")) { constructors.add(mi); } else { methods.add(mi); } return mi; } @Override public String getPackageName() { return packageName; } @Override public String getName() { return name; } @Override public String getQualifiedName() { return qualifiedName; } @Override public Collection getFields() { return fields; } @Override public Collection getConstructors() { return constructors; } @Override public Collection getMethods() { return methods; } @Override public ClassInfo getSuperClass() { return classInfos.get(superName); } @Override public void visitInnerClass(String name, String outerName, String innerName, int access) { if (name.equals(idName)) { declaringClass = outerName; } super.visitInnerClass(name, outerName, innerName, access); } @Override public void visitOuterClass(String owner, String name, String desc) { isInner = true; } @Override public ClassInfo getDeclaringClass() { if (declaringClass != null) { return classInfos.get(declaringClass); } else { return null; } } @Override public boolean isAbstract() { return (access & Opcodes.ACC_ABSTRACT) > 0; } @Override public boolean isPublic() { return (access & Opcodes.ACC_PUBLIC) > 0; } @Override public boolean isStrictFP() { return (access & Opcodes.ACC_STRICT) > 0; } @Override public boolean isFinal() { return (access & Opcodes.ACC_FINAL) > 0; } @Override public boolean isInner() { return isInner; } @Override public boolean isEnum() { return (access & Opcodes.ACC_ENUM) > 0; } @Override public Collection getEnumConstants() { if (isEnum()) { try { Collection res = new ArrayList<>(); for (Object cnst : Class.forName(origQualifiedName, false, Thread.currentThread().getContextClassLoader()).getEnumConstants()) { res.add(((Enum) cnst).name()); } return res; } catch (ClassNotFoundException e) { throw new IllegalStateException("Can not find and instantiate enum: " + origQualifiedName); } } else { return Collections.emptyList(); } } @Override public String toString() { return qualifiedName; } } jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMFieldInfo.java000066400000000000000000000072341446271450100312030ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.asm; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.FieldInfo; import java.lang.annotation.Annotation; import java.lang.reflect.Proxy; import java.util.HashMap; import java.util.Map; class ASMFieldInfo extends FieldVisitor implements FieldInfo { private final ClassInfo type; private final ASMClassInfo declaringClass; private final int access; private final String name; private final Map annotations; public ASMFieldInfo(FieldVisitor fieldVisitor, ASMClassInfo declaringClass, int access, String name, ClassInfo type) { super(Opcodes.ASM5, fieldVisitor); this.declaringClass = declaringClass; this.access = access; this.name = name; this.type = type; this.annotations = new HashMap<>(); } @Override public String getName() { return name; } @Override public ClassInfo getType() { return type; } @Override public boolean isPublic() { return (access & Opcodes.ACC_PUBLIC) > 0; } @Override public boolean isStatic() { return (access & Opcodes.ACC_STATIC) > 0; } @Override public boolean isFinal() { return (access & Opcodes.ACC_FINAL) > 0; } @Override public T getAnnotation(Class annClass) { AnnotationInvocationHandler handler = annotations.get(annClass.getCanonicalName()); if (handler == null) { return null; } else { return (T) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[]{annClass}, handler); } } @Override public AnnotationVisitor visitAnnotation(final String desc, boolean visible) { String className = Type.getType(desc).getClassName(); AnnotationInvocationHandler annHandler = new AnnotationInvocationHandler(className, super.visitAnnotation(desc, visible)); annotations.put(className, annHandler); return annHandler; } @Override public ClassInfo getDeclaringClass() { return declaringClass; } @Override public String toString() { return declaringClass.getQualifiedName() + "." + name; } } jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMGeneratorSource.java000066400000000000000000000050141446271450100324450ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.asm; import org.objectweb.asm.ClassReader; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.GeneratorSource; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Collection; public class ASMGeneratorSource implements GeneratorSource { private final ClassInfoRepo classInfos; public ASMGeneratorSource() { this.classInfos = new ClassInfoRepo(); } public void processClasses(Collection classFiles) throws IOException { for (File f : classFiles) { processClass(f); } } public void processClass(File classFile) throws IOException { try (FileInputStream fis = new FileInputStream(classFile)){ processClass(fis); } } public void processClass(InputStream stream) throws IOException { final ASMClassInfo ci = new ASMClassInfo(classInfos); ClassReader reader = new ClassReader(stream); reader.accept(ci, 0); classInfos.put(ci.getIdName(), ci); } @Override public Collection getClasses() { return classInfos.getInfos(); } @Override public ClassInfo resolveClass(String className) { return classInfos.get(className); } } jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMMethodInfo.java000066400000000000000000000114241446271450100313740ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.asm; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.MethodInfo; import org.openjdk.jmh.generators.core.ParameterInfo; import java.lang.annotation.Annotation; import java.lang.reflect.Proxy; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; class ASMMethodInfo extends MethodVisitor implements MethodInfo { private final ASMClassInfo declaringClass; private final Map annotations; private final int access; private final String name; private final String returnType; private final Type[] argumentTypes; private final ClassInfoRepo repo; public ASMMethodInfo(MethodVisitor methodVisitor, ClassInfoRepo repo, ASMClassInfo declaringClass, int access, String name, String desc, String signature) { super(Opcodes.ASM5, methodVisitor); this.declaringClass = declaringClass; this.repo = repo; this.access = access; this.name = name; this.returnType = Type.getReturnType(desc).getClassName(); this.annotations = new HashMap<>(); this.argumentTypes = Type.getArgumentTypes(desc); } @Override public T getAnnotation(Class annClass) { AnnotationInvocationHandler handler = annotations.get(annClass.getCanonicalName()); if (handler == null) { return null; } else { return (T) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[]{annClass}, handler); } } @Override public AnnotationVisitor visitAnnotation(final String desc, boolean visible) { String className = Type.getType(desc).getClassName(); AnnotationInvocationHandler annHandler = new AnnotationInvocationHandler(className, super.visitAnnotation(desc, visible)); annotations.put(className, annHandler); return annHandler; } @Override public ClassInfo getDeclaringClass() { return declaringClass; } @Override public String getName() { return name; } @Override public String getQualifiedName() { return declaringClass.getQualifiedName() + "." + name; } @Override public String getReturnType() { return returnType; } @Override public Collection getParameters() { Collection result = new ArrayList<>(); for (Type t : argumentTypes) { ClassInfo ci = repo.get(t.getClassName()); result.add(new ASMParameterInfo(ci)); } return result; } @Override public boolean isPublic() { return (access & Opcodes.ACC_PUBLIC) > 0; } @Override public boolean isAbstract() { return (access & Opcodes.ACC_ABSTRACT) > 0; } @Override public boolean isSynchronized() { return (access & Opcodes.ACC_SYNCHRONIZED) > 0; } @Override public boolean isStrictFP() { return (access & Opcodes.ACC_STRICT) > 0; } @Override public boolean isStatic() { return (access & Opcodes.ACC_STATIC) > 0; } @Override public int compareTo(MethodInfo o) { return getQualifiedName().compareTo(o.getQualifiedName()); } @Override public String toString() { return getQualifiedName() + "()"; } } jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMParameterInfo.java000066400000000000000000000030661446271450100320770ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.asm; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.ParameterInfo; class ASMParameterInfo implements ParameterInfo { private final ClassInfo ci; public ASMParameterInfo(ClassInfo ci) { this.ci = ci; } @Override public ClassInfo getType() { return ci; } } AnnotationInvocationHandler.java000066400000000000000000000175251446271450100343720ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.asm; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.Opcodes; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import java.lang.reflect.Array; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Collection; import java.util.HashSet; import java.util.Set; class AnnotationInvocationHandler extends AnnotationVisitor implements InvocationHandler { private final String className; private final Multimap values; public AnnotationInvocationHandler(String className, AnnotationVisitor annotationVisitor) { super(Opcodes.ASM5, annotationVisitor); this.className = className; this.values = new HashMultimap<>(); } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String member = method.getName(); Class returnType = method.getReturnType(); Class[] paramTypes = method.getParameterTypes(); if (member.equals("equals") && paramTypes.length == 1 && paramTypes[0] == Object.class) return equalsImpl(args[0]); if (paramTypes.length != 0) throw new AssertionError("Too many parameters for an annotation method"); switch (member) { case "toString": return toStringImpl(); case "hashCode": return hashcodeImpl(); case "annotationType": throw new IllegalStateException("annotationType is not implemented"); } /* Unfortunately, we can not pre-process these values when walking the annotation with ASM, since we are oblivious of exact types. Try to match the observed values right here, based on the method return type. */ Collection vs = values.get(member); if (vs == null || vs.isEmpty()) { return method.getDefaultValue(); } if (!returnType.isArray()) { Object res = peelSingle(vs); if (returnType.isEnum()) { return parseEnum(returnType, res); } // String will return as is; primitive will auto-box return res; } else { Class componentType = returnType.getComponentType(); if (componentType.isEnum()) { // Dealing with Enum[]: Object res = Array.newInstance(componentType, vs.size()); int c = 0; for (Object v : vs) { Array.set(res, c, parseEnum(componentType, v)); c++; } return res; } else if (componentType.isAssignableFrom(String.class)) { // Dealing with String[]: return vs.toArray(new String[0]); } else { // "Dealing" with primitive array: // We do not have any primitive-array-valued annotations yet, so we don't bother to implement this. throw new IllegalStateException("Primitive arrays are not handled yet"); } } } private Object peelSingle(Collection vs) { Object res; if (vs.size() == 1) { res = vs.iterator().next(); } else { throw new IllegalStateException("Expected to see a single value, but got " + vs.size()); } return res; } private String toStringImpl() { StringBuilder sb = new StringBuilder(); sb.append("@"); sb.append(className); sb.append("("); for (String k : values.keys()) { sb.append(k); sb.append(" = "); sb.append(values.get(k)); sb.append(", "); } sb.append(")"); return sb.toString(); } private Object parseEnum(Class type, Object res) throws Exception { if (res == null) { throw new IllegalStateException("The argument is null"); } if (!(res instanceof String)) { throw new IllegalStateException("The argument is not String, but " + res.getClass()); } Method m = type.getMethod("valueOf", String.class); return m.invoke(null, res); } private int hashcodeImpl() { int result = className.hashCode(); for (String k : values.keys()) { result = 31 * result + k.hashCode(); } return result; } private boolean equalsImpl(Object arg) { AnnotationInvocationHandler other = asOneOfUs(arg); if (other != null) { if (!className.equals(other.className)) { return false; } Set keys = new HashSet<>(); keys.addAll(values.keys()); keys.addAll(other.values.keys()); for (String k : keys) { Collection o1 = values.get(k); Collection o2 = other.values.get(k); if (o1 == null || o2 == null) { return false; } if (o1.size() != o2.size()) { return false; } if (!o1.containsAll(o2) || !o2.containsAll(o1)) { return false; } } return true; } else { throw new IllegalStateException("Expected to see only AnnotationInvocationHandler-backed annotations"); } } private AnnotationInvocationHandler asOneOfUs(Object o) { if (Proxy.isProxyClass(o.getClass())) { InvocationHandler handler = Proxy.getInvocationHandler(o); if (handler instanceof AnnotationInvocationHandler) return (AnnotationInvocationHandler) handler; } return null; } @Override public void visit(String name, Object value) { values.put(name, value); super.visit(name, value); } @Override public void visitEnum(String name, String desc, String value) { values.put(name, value); super.visitEnum(name, desc, value); } @Override public AnnotationVisitor visitArray(final String name) { return new AnnotationVisitor(Opcodes.ASM5, super.visitArray(name)) { @Override public void visitEnum(String n, String desc, String value) { values.put(name, value); super.visitEnum(n, desc, value); } @Override public void visit(String n, Object value) { values.put(name, value); super.visit(n, value); } }; } } jmh-1.37/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ClassInfoRepo.java000066400000000000000000000100651446271450100315060ustar00rootroot00000000000000/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.asm; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.reflection.RFGeneratorSource; import java.util.Collection; import java.util.HashMap; import java.util.Map; class ClassInfoRepo { private final Map map = new HashMap<>(); public ClassInfo get(String desc) { desc = desc.replace('/', '.'); ClassInfo info = map.get(desc); if (info != null) { return info; } if (desc.equals(boolean.class.getCanonicalName())) return RFGeneratorSource.resolveClass(boolean.class); if (desc.equals(byte.class.getCanonicalName())) return RFGeneratorSource.resolveClass(byte.class); if (desc.equals(char.class.getCanonicalName())) return RFGeneratorSource.resolveClass(char.class); if (desc.equals(short.class.getCanonicalName())) return RFGeneratorSource.resolveClass(short.class); if (desc.equals(int.class.getCanonicalName())) return RFGeneratorSource.resolveClass(int.class); if (desc.equals(float.class.getCanonicalName())) return RFGeneratorSource.resolveClass(float.class); if (desc.equals(long.class.getCanonicalName())) return RFGeneratorSource.resolveClass(long.class); if (desc.equals(double.class.getCanonicalName())) return RFGeneratorSource.resolveClass(double.class); if (desc.equals(boolean[].class.getCanonicalName())) return RFGeneratorSource.resolveClass(boolean[].class); if (desc.equals(byte[].class.getCanonicalName())) return RFGeneratorSource.resolveClass(byte[].class); if (desc.equals(char[].class.getCanonicalName())) return RFGeneratorSource.resolveClass(char[].class); if (desc.equals(short[].class.getCanonicalName())) return RFGeneratorSource.resolveClass(short[].class); if (desc.equals(int[].class.getCanonicalName())) return RFGeneratorSource.resolveClass(int[].class); if (desc.equals(float[].class.getCanonicalName())) return RFGeneratorSource.resolveClass(float[].class); if (desc.equals(long[].class.getCanonicalName())) return RFGeneratorSource.resolveClass(long[].class); if (desc.equals(double[].class.getCanonicalName())) return RFGeneratorSource.resolveClass(double[].class); if (desc.endsWith("[]")) { desc = "[L" + desc.substring(0, desc.length() - 2) + ";"; } try { return RFGeneratorSource.resolveClass(Class.forName(desc, false, Thread.currentThread().getContextClassLoader())); } catch (ClassNotFoundException e) { throw new IllegalStateException("Unable to resolve class: " + desc); } } public void put(String desc, ClassInfo info) { desc = desc.replace('/', '.'); map.put(desc, info); } public Collection getInfos() { return map.values(); } } jmh-1.37/jmh-generator-asm/src/main/resources/000077500000000000000000000000001446271450100212735ustar00rootroot00000000000000jmh-1.37/jmh-generator-asm/src/main/resources/LICENSE000066400000000000000000000455121446271450100223070ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-generator-asm/src/main/resources/THIRD-PARTY000066400000000000000000000350611446271450100227720ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-generator-bytecode/000077500000000000000000000000001446271450100165645ustar00rootroot00000000000000jmh-1.37/jmh-generator-bytecode/LICENSE000066400000000000000000000455121446271450100176000ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-generator-bytecode/THIRD-PARTY000066400000000000000000000350611446271450100202630ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-generator-bytecode/pom.xml000066400000000000000000000117541446271450100201110ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent 1.37 JMH Generators: Bytecode jmh-generator-bytecode jar JMH benchmark generator, based on bytecode inspection. org.openjdk.jmh jmh-core ${project.version} org.openjdk.jmh jmh-generator-reflection ${project.version} org.openjdk.jmh jmh-generator-asm ${project.version} UTF-8 org.apache.maven.plugins maven-compiler-plugin -proc:none org.apache.maven.plugins maven-surefire-plugin false com.mycila.maven-license-plugin maven-license-plugin format process-sources
file:///${project.basedir}/../src/license/gpl_cpe/header.txt
true true PHP
org.apache.maven.plugins maven-shade-plugin package shade jmh-bytecode-generator org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator
jmh-1.37/jmh-generator-bytecode/src/000077500000000000000000000000001446271450100173535ustar00rootroot00000000000000jmh-1.37/jmh-generator-bytecode/src/main/000077500000000000000000000000001446271450100202775ustar00rootroot00000000000000jmh-1.37/jmh-generator-bytecode/src/main/java/000077500000000000000000000000001446271450100212205ustar00rootroot00000000000000jmh-1.37/jmh-generator-bytecode/src/main/java/org/000077500000000000000000000000001446271450100220075ustar00rootroot00000000000000jmh-1.37/jmh-generator-bytecode/src/main/java/org/openjdk/000077500000000000000000000000001446271450100234415ustar00rootroot00000000000000jmh-1.37/jmh-generator-bytecode/src/main/java/org/openjdk/jmh/000077500000000000000000000000001446271450100242175ustar00rootroot00000000000000jmh-1.37/jmh-generator-bytecode/src/main/java/org/openjdk/jmh/generators/000077500000000000000000000000001446271450100263705ustar00rootroot00000000000000jmh-1.37/jmh-generator-bytecode/src/main/java/org/openjdk/jmh/generators/bytecode/000077500000000000000000000000001446271450100301665ustar00rootroot00000000000000JmhBytecodeGenerator.java000066400000000000000000000115511446271450100350210ustar00rootroot00000000000000jmh-1.37/jmh-generator-bytecode/src/main/java/org/openjdk/jmh/generators/bytecode/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.bytecode; import org.openjdk.jmh.generators.asm.ASMGeneratorSource; import org.openjdk.jmh.generators.core.BenchmarkGenerator; import org.openjdk.jmh.generators.core.FileSystemDestination; import org.openjdk.jmh.generators.core.GeneratorSource; import org.openjdk.jmh.generators.core.SourceError; import org.openjdk.jmh.generators.reflection.RFGeneratorSource; import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.net.URL; import java.net.URLClassLoader; import java.util.Collection; public class JmhBytecodeGenerator { public static final String GENERATOR_TYPE_DEFAULT = "default"; public static final String GENERATOR_TYPE_ASM = "asm"; public static final String GENERATOR_TYPE_REFLECTION = "reflection"; public static final String DEFAULT_GENERATOR_TYPE = GENERATOR_TYPE_REFLECTION; public static void main(String[] args) throws Exception { if (args.length < 3 || args.length > 4) { System.err.println("Usage: generator [generator-type]"); System.exit(1); } File compiledBytecodeDirectory = new File(args[0]); File outputSourceDirectory = new File(args[1]); File outputResourceDirectory = new File(args[2]); String generatorType = DEFAULT_GENERATOR_TYPE; if (args.length >= 4) { if (!args[3].equalsIgnoreCase(GENERATOR_TYPE_DEFAULT)) { generatorType = args[3]; } } // Include compiled bytecode on classpath, in case we need to // resolve the cross-class dependencies URLClassLoader amendedCL = new URLClassLoader( new URL[]{compiledBytecodeDirectory.toURI().toURL()}, Thread.currentThread().getContextClassLoader()); Thread.currentThread().setContextClassLoader(amendedCL); FileSystemDestination destination = new FileSystemDestination(outputResourceDirectory, outputSourceDirectory); Collection classes = FileUtils.getClasses(compiledBytecodeDirectory); System.out.println("Processing " + classes.size() + " classes from " + compiledBytecodeDirectory + " with \"" + generatorType + "\" generator"); System.out.println("Writing out Java source to " + outputSourceDirectory + " and resources to " + outputResourceDirectory); GeneratorSource source = null; if (generatorType.equalsIgnoreCase(GENERATOR_TYPE_ASM)) { ASMGeneratorSource src = new ASMGeneratorSource(); src.processClasses(classes); source = src; } else if (generatorType.equalsIgnoreCase(GENERATOR_TYPE_REFLECTION)) { RFGeneratorSource src = new RFGeneratorSource(); for (File f : classes) { String name = f.getAbsolutePath().substring(compiledBytecodeDirectory.getAbsolutePath().length() + 1); name = name.replaceAll("\\\\", "."); name = name.replaceAll("/", "."); if (name.endsWith(".class")) { src.processClasses(Class.forName(name.substring(0, name.length() - 6), false, amendedCL)); } } source = src; } else { System.err.println("Unknown generator type: " + generatorType); System.exit(1); } BenchmarkGenerator gen = new BenchmarkGenerator(); gen.generate(source, destination); gen.complete(source, destination); if (destination.hasErrors()) { for (SourceError e : destination.getErrors()) { System.err.println(e.toString() + "\n"); } System.exit(1); } } } jmh-1.37/jmh-generator-bytecode/src/main/resources/000077500000000000000000000000001446271450100223115ustar00rootroot00000000000000jmh-1.37/jmh-generator-bytecode/src/main/resources/LICENSE000066400000000000000000000455121446271450100233250ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-generator-bytecode/src/main/resources/THIRD-PARTY000066400000000000000000000350611446271450100240100ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-generator-reflection/000077500000000000000000000000001446271450100171205ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/LICENSE000066400000000000000000000455121446271450100201340ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-generator-reflection/THIRD-PARTY000066400000000000000000000350611446271450100206170ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-generator-reflection/pom.xml000066400000000000000000000071321446271450100204400ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent 1.37 JMH Generators: Reflection jmh-generator-reflection jar JMH benchmark generator, based on reflection. org.openjdk.jmh jmh-core ${project.version} UTF-8 org.apache.maven.plugins maven-compiler-plugin -proc:none org.apache.maven.plugins maven-surefire-plugin false com.mycila.maven-license-plugin maven-license-plugin format process-sources
file:///${project.basedir}/../src/license/gpl_cpe/header.txt
true true PHP
jmh-1.37/jmh-generator-reflection/src/000077500000000000000000000000001446271450100177075ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/000077500000000000000000000000001446271450100206335ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/000077500000000000000000000000001446271450100215545ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/000077500000000000000000000000001446271450100223435ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/openjdk/000077500000000000000000000000001446271450100237755ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/openjdk/jmh/000077500000000000000000000000001446271450100245535ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/000077500000000000000000000000001446271450100267245ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/000077500000000000000000000000001446271450100310565ustar00rootroot00000000000000RFClassInfo.java000066400000000000000000000122241446271450100337540ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.reflection; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.FieldInfo; import org.openjdk.jmh.generators.core.MethodInfo; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; class RFClassInfo implements ClassInfo { private final Class klass; public RFClassInfo(Class klass) { this.klass = klass; } @Override public String getPackageName() { if (klass.getDeclaringClass() != null) { return nameOf(klass.getDeclaringClass().getPackage()); } else { return nameOf(klass.getPackage()); } } @Override public String getName() { String name = klass.getSimpleName(); if (name.contains("$")) { return name.substring(name.lastIndexOf("$")); } else { return name; } } @Override public String getQualifiedName() { String name = klass.getCanonicalName(); if (name == null) { name = klass.getName(); } if (name.contains("$")) { return name.replace("$", "."); } else { return name; } } @Override public Collection getFields() { Collection fis = new ArrayList<>(); for (Field f : klass.getDeclaredFields()) { fis.add(new RFFieldInfo(this, f)); } return fis; } @Override public Collection getConstructors() { Collection mis = new ArrayList<>(); for (Constructor m : klass.getDeclaredConstructors()) { mis.add(new RFConstructorInfo(this, m)); } return mis; } @Override public Collection getMethods() { Collection mis = new ArrayList<>(); for (Method m : klass.getDeclaredMethods()) { mis.add(new RFMethodInfo(this, m)); } return mis; } @Override public ClassInfo getSuperClass() { if (klass.getSuperclass() != null) { return new RFClassInfo(klass.getSuperclass()); } else { return null; } } @Override public ClassInfo getDeclaringClass() { if (klass.getDeclaringClass() != null) { return new RFClassInfo(klass.getDeclaringClass()); } else { return null; } } @Override public T getAnnotation(Class annClass) { return klass.getAnnotation(annClass); } @Override public boolean isAbstract() { return Modifier.isAbstract(klass.getModifiers()); } @Override public boolean isPublic() { return Modifier.isPublic(klass.getModifiers()); } @Override public boolean isStrictFP() { return Modifier.isStrict(klass.getModifiers()); } @Override public boolean isFinal() { return Modifier.isFinal(klass.getModifiers()); } @Override public boolean isInner() { // LOL, Reflection: http://mail.openjdk.java.net/pipermail/core-libs-dev/2014-February/025246.html return klass.isAnonymousClass() || klass.isLocalClass() || (klass.isMemberClass() && !Modifier.isStatic(klass.getModifiers())); } @Override public boolean isEnum() { return klass.isEnum(); } @Override public Collection getEnumConstants() { Collection res = new ArrayList<>(); for (Object cnst : klass.getEnumConstants()) { res.add(((Enum) cnst).name()); } return res; } @Override public String toString() { return getQualifiedName(); } private String nameOf(Package pack) { return pack == null ? "" : pack.getName(); } } RFConstructorInfo.java000066400000000000000000000065271446271450100352450ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.reflection; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.MethodInfo; import org.openjdk.jmh.generators.core.ParameterInfo; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; class RFConstructorInfo implements MethodInfo { private final RFClassInfo declaringClass; private final Constructor m; public RFConstructorInfo(RFClassInfo declaringClass, Constructor m) { this.declaringClass = declaringClass; this.m = m; } @Override public ClassInfo getDeclaringClass() { return declaringClass; } @Override public String getName() { return m.getName(); } @Override public String getQualifiedName() { return declaringClass.getQualifiedName() + "." + m.getName(); } @Override public String getReturnType() { throw new IllegalStateException("Asking the return type for constructor"); } @Override public Collection getParameters() { Collection pis = new ArrayList<>(); for (Class cl : m.getParameterTypes()) { pis.add(new RFParameterInfo(cl)); } return pis; } @Override public T getAnnotation(Class annClass) { throw new IllegalStateException("Asking annotations for constructor"); } @Override public boolean isPublic() { return Modifier.isPublic(m.getModifiers()); } @Override public boolean isAbstract() { return Modifier.isAbstract(m.getModifiers()); } @Override public boolean isSynchronized() { return Modifier.isSynchronized(m.getModifiers()); } @Override public boolean isStrictFP() { return Modifier.isStrict(m.getModifiers()); } @Override public boolean isStatic() { return Modifier.isStatic(m.getModifiers()); } @Override public int compareTo(MethodInfo o) { return getQualifiedName().compareTo(o.getQualifiedName()); } } RFFieldInfo.java000066400000000000000000000047771446271450100337500ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.reflection; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.FieldInfo; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Modifier; class RFFieldInfo implements FieldInfo { private final ClassInfo declaringClass; private final Field f; public RFFieldInfo(ClassInfo declaringClass, Field f) { this.declaringClass = declaringClass; this.f = f; } @Override public ClassInfo getDeclaringClass() { return declaringClass; } @Override public String getName() { return f.getName(); } @Override public ClassInfo getType() { return new RFClassInfo(f.getType()); } @Override public T getAnnotation(Class annClass) { return f.getAnnotation(annClass); } @Override public boolean isPublic() { return Modifier.isPublic(f.getModifiers()); } @Override public boolean isStatic() { return Modifier.isStatic(f.getModifiers()); } @Override public boolean isFinal() { return Modifier.isFinal(f.getModifiers()); } @Override public String toString() { return declaringClass.getQualifiedName() + "." + f.getName(); } } RFGeneratorSource.java000066400000000000000000000047621446271450100352120ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.reflection; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.GeneratorSource; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; public class RFGeneratorSource implements GeneratorSource { private final Collection classes; public RFGeneratorSource() { this.classes = new ArrayList<>(); } @Override public Collection getClasses() { Collection cis = new ArrayList<>(); for (Class c : classes) { cis.add(new RFClassInfo(c)); } return cis; } public static ClassInfo resolveClass(Class klass) { return new RFClassInfo(klass); } @Override public ClassInfo resolveClass(String className) { String desc = className.replace('/', '.'); try { return resolveClass(Class.forName(desc, false, Thread.currentThread().getContextClassLoader())); } catch (ClassNotFoundException e) { throw new IllegalStateException("Unable to resolve class: " + desc); } } public void processClasses(Class... cs) { processClasses(Arrays.asList(cs)); } public void processClasses(Collection cs) { classes.addAll(cs); } } RFMethodInfo.java000066400000000000000000000063731446271450100341370ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.reflection; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.MethodInfo; import org.openjdk.jmh.generators.core.ParameterInfo; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; class RFMethodInfo implements MethodInfo { private final RFClassInfo declaringClass; private final Method m; public RFMethodInfo(RFClassInfo declaringClass, Method m) { this.declaringClass = declaringClass; this.m = m; } @Override public ClassInfo getDeclaringClass() { return declaringClass; } @Override public String getName() { return m.getName(); } @Override public String getQualifiedName() { return declaringClass.getQualifiedName() + "." + m.getName(); } @Override public String getReturnType() { return m.getReturnType().getCanonicalName(); } @Override public Collection getParameters() { Collection pis = new ArrayList<>(); for (Class cl : m.getParameterTypes()) { pis.add(new RFParameterInfo(cl)); } return pis; } @Override public T getAnnotation(Class annClass) { return m.getAnnotation(annClass); } @Override public boolean isPublic() { return Modifier.isPublic(m.getModifiers()); } @Override public boolean isAbstract() { return Modifier.isAbstract(m.getModifiers()); } @Override public boolean isSynchronized() { return Modifier.isSynchronized(m.getModifiers()); } @Override public boolean isStrictFP() { return Modifier.isStrict(m.getModifiers()); } @Override public boolean isStatic() { return Modifier.isStatic(m.getModifiers()); } @Override public int compareTo(MethodInfo o) { return getQualifiedName().compareTo(o.getQualifiedName()); } } RFParameterInfo.java000066400000000000000000000031111446271450100346220ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jmh.generators.reflection; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.ParameterInfo; class RFParameterInfo implements ParameterInfo { private final Class cl; public RFParameterInfo(Class cl) { this.cl = cl; } @Override public ClassInfo getType() { return new RFClassInfo(cl); } } jmh-1.37/jmh-generator-reflection/src/main/resources/000077500000000000000000000000001446271450100226455ustar00rootroot00000000000000jmh-1.37/jmh-generator-reflection/src/main/resources/LICENSE000066400000000000000000000455121446271450100236610ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/jmh-generator-reflection/src/main/resources/THIRD-PARTY000066400000000000000000000350611446271450100243440ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-samples/000077500000000000000000000000001446271450100144465ustar00rootroot00000000000000jmh-1.37/jmh-samples/LICENSE000066400000000000000000000027231446271450100154570ustar00rootroot00000000000000Copyright (c) 2014, Oracle America, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Oracle nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.jmh-1.37/jmh-samples/THIRD-PARTY000066400000000000000000000350611446271450100161450ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/jmh-samples/pom.xml000066400000000000000000000124601446271450100157660ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent 1.37 JMH Samples jmh-samples jar Oracle http://openjdk.java.net/ 2012 org.openjdk.jmh jmh-core ${project.version} org.openjdk.jmh jmh-generator-annprocess ${project.version} provided UTF-8 benchmarks org.apache.maven.plugins maven-compiler-plugin org.apache.maven.plugins maven-surefire-plugin always true org.apache.maven.plugins maven-shade-plugin package shade ${uberjar.name} org.openjdk.jmh.Main com.mycila.maven-license-plugin maven-license-plugin format process-sources
file:///${project.basedir}/../src/license/bsd/header.txt
true true PHP
jmh-1.37/jmh-samples/src/000077500000000000000000000000001446271450100152355ustar00rootroot00000000000000jmh-1.37/jmh-samples/src/main/000077500000000000000000000000001446271450100161615ustar00rootroot00000000000000jmh-1.37/jmh-samples/src/main/java/000077500000000000000000000000001446271450100171025ustar00rootroot00000000000000jmh-1.37/jmh-samples/src/main/java/org/000077500000000000000000000000001446271450100176715ustar00rootroot00000000000000jmh-1.37/jmh-samples/src/main/java/org/openjdk/000077500000000000000000000000001446271450100213235ustar00rootroot00000000000000jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/000077500000000000000000000000001446271450100221015ustar00rootroot00000000000000jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/000077500000000000000000000000001446271450100235455ustar00rootroot00000000000000jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_01_HelloWorld.java000066400000000000000000000110211446271450100306160ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; public class JMHSample_01_HelloWorld { /* * This is our first benchmark method. * * JMH works as follows: users annotate the methods with @Benchmark, and * then JMH produces the generated code to run this particular benchmark as * reliably as possible. In general one might think about @Benchmark methods * as the benchmark "payload", the things we want to measure. The * surrounding infrastructure is provided by the harness itself. * * Read the Javadoc for @Benchmark annotation for complete semantics and * restrictions. At this point we only note that the methods names are * non-essential, and it only matters that the methods are marked with * @Benchmark. You can have multiple benchmark methods within the same * class. * * Note: if the benchmark method never finishes, then JMH run never finishes * as well. If you throw an exception from the method body the JMH run ends * abruptly for this benchmark and JMH will run the next benchmark down the * list. * * Although this benchmark measures "nothing" it is a good showcase for the * overheads the infrastructure bear on the code you measure in the method. * There are no magical infrastructures which incur no overhead, and it is * important to know what are the infra overheads you are dealing with. You * might find this thought unfolded in future examples by having the * "baseline" measurements to compare against. */ @Benchmark public void wellHelloThere() { // this method was intentionally left blank. } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You are expected to see the run with large number of iterations, and * very large throughput numbers. You can see that as the estimate of the * harness overheads per method call. In most of our measurements, it is * down to several cycles per call. * * a) Via command-line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_01 * * JMH generates self-contained JARs, bundling JMH together with it. * The runtime options for the JMH are available with "-h": * $ java -jar target/benchmarks.jar -h * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_01_HelloWorld.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java000066400000000000000000000160501446271450100314350ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; public class JMHSample_02_BenchmarkModes { /* * JMH generates lots of synthetic code for the benchmarks for you during * the benchmark compilation. JMH can measure the benchmark methods in lots * of modes. Users may select the default benchmark mode with a special * annotation, or select/override the mode via the runtime options. * * With this scenario, we start to measure something useful. Note that our * payload code potentially throws exceptions, and we can just declare them * to be thrown. If the code throws the actual exception, the benchmark * execution will stop with an error. * * When you are puzzled with some particular behavior, it usually helps to * look into the generated code. You might see the code is doing not * something you intend it to do. Good experiments always follow up on the * experimental setup, and cross-checking the generated code is an important * part of that follow up. * * The generated code for this particular sample is somewhere at * target/generated-sources/annotations/.../JMHSample_02_BenchmarkModes.java */ /* * Mode.Throughput, as stated in its Javadoc, measures the raw throughput by * continuously calling the benchmark method in a time-bound iteration, and * counting how many times we executed the method. * * We are using the special annotation to select the units to measure in, * although you can use the default. */ @Benchmark @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) public void measureThroughput() throws InterruptedException { TimeUnit.MILLISECONDS.sleep(100); } /* * Mode.AverageTime measures the average execution time, and it does it * in the way similar to Mode.Throughput. * * Some might say it is the reciprocal throughput, and it really is. * There are workloads where measuring times is more convenient though. */ @Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void measureAvgTime() throws InterruptedException { TimeUnit.MILLISECONDS.sleep(100); } /* * Mode.SampleTime samples the execution time. With this mode, we are * still running the method in a time-bound iteration, but instead of * measuring the total time, we measure the time spent in *some* of * the benchmark method calls. * * This allows us to infer the distributions, percentiles, etc. * * JMH also tries to auto-adjust sampling frequency: if the method * is long enough, you will end up capturing all the samples. */ @Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void measureSamples() throws InterruptedException { TimeUnit.MILLISECONDS.sleep(100); } /* * Mode.SingleShotTime measures the single method invocation time. As the Javadoc * suggests, we do only the single benchmark method invocation. The iteration * time is meaningless in this mode: as soon as benchmark method stops, the * iteration is over. * * This mode is useful to do cold startup tests, when you specifically * do not want to call the benchmark method continuously. */ @Benchmark @BenchmarkMode(Mode.SingleShotTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void measureSingleShot() throws InterruptedException { TimeUnit.MILLISECONDS.sleep(100); } /* * We can also ask for multiple benchmark modes at once. All the tests * above can be replaced with just a single test like this: */ @Benchmark @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime, Mode.SingleShotTime}) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void measureMultiple() throws InterruptedException { TimeUnit.MILLISECONDS.sleep(100); } /* * Or even... */ @Benchmark @BenchmarkMode(Mode.All) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void measureAll() throws InterruptedException { TimeUnit.MILLISECONDS.sleep(100); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You are expected to see the different run modes for the same benchmark. * Note the units are different, scores are consistent with each other. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_02 -f 1 * (we requested a single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_02_BenchmarkModes.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java000066400000000000000000000116401446271450100300170ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; public class JMHSample_03_States { /* * Most of the time, you need to maintain some state while the benchmark is * running. Since JMH is heavily used to build concurrent benchmarks, we * opted for an explicit notion of state-bearing objects. * * Below are two state objects. Their class names are not essential, it * matters they are marked with @State. These objects will be instantiated * on demand, and reused during the entire benchmark trial. * * The important property is that state is always instantiated by one of * those benchmark threads which will then have the access to that state. * That means you can initialize the fields as if you do that in worker * threads (ThreadLocals are yours, etc). */ @State(Scope.Benchmark) public static class BenchmarkState { volatile double x = Math.PI; } @State(Scope.Thread) public static class ThreadState { volatile double x = Math.PI; } /* * Benchmark methods can reference the states, and JMH will inject the * appropriate states while calling these methods. You can have no states at * all, or have only one state, or have multiple states referenced. This * makes building multi-threaded benchmark a breeze. * * For this exercise, we have two methods. */ @Benchmark public void measureUnshared(ThreadState state) { // All benchmark threads will call in this method. // // However, since ThreadState is the Scope.Thread, each thread // will have it's own copy of the state, and this benchmark // will measure unshared case. state.x++; } @Benchmark public void measureShared(BenchmarkState state) { // All benchmark threads will call in this method. // // Since BenchmarkState is the Scope.Benchmark, all threads // will share the state instance, and we will end up measuring // shared case. state.x++; } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You are expected to see the drastic difference in shared and unshared cases, * because you either contend for single memory location, or not. This effect * is more articulated on large machines. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_03 -t 4 -f 1 * (we requested 4 threads, single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_03_States.class.getSimpleName()) .threads(4) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_04_DefaultState.java000066400000000000000000000061341446271450100311440ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; /* * Fortunately, in many cases you just need a single state object. * In that case, we can mark the benchmark instance itself to be * the @State. Then, we can reference its own fields as any * Java program does. */ @State(Scope.Thread) public class JMHSample_04_DefaultState { double x = Math.PI; @Benchmark public void measure() { x++; } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can see the benchmark runs as usual. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_04 -f 1 * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_04_DefaultState.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_05_StateFixtures.java000066400000000000000000000111121446271450100313620ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; @State(Scope.Thread) public class JMHSample_05_StateFixtures { double x; /* * Since @State objects are kept around during the lifetime of the * benchmark, it helps to have the methods which do state housekeeping. * These are usual fixture methods, you are probably familiar with them from * JUnit and TestNG. * * Fixture methods make sense only on @State objects, and JMH will fail to * compile the test otherwise. * * As with the State, fixture methods are only called by those benchmark * threads which are using the state. That means you can operate in the * thread-local context, and (not) use synchronization as if you are * executing in the context of benchmark thread. * * Note: fixture methods can also work with static fields, although the * semantics of these operations fall back out of State scope, and obey * usual Java rules (i.e. one static field per class). */ /* * Ok, let's prepare our benchmark: */ @Setup public void prepare() { x = Math.PI; } /* * And, check the benchmark went fine afterwards: */ @TearDown public void check() { assert x > Math.PI : "Nothing changed?"; } /* * This method obviously does the right thing, incrementing the field x * in the benchmark state. check() will never fail this way, because * we are always guaranteed to have at least one benchmark call. */ @Benchmark public void measureRight() { x++; } /* * This method, however, will fail the check(), because we deliberately * have the "typo", and increment only the local variable. This should * not pass the check, and JMH will fail the run. */ @Benchmark public void measureWrong() { double x = 0; x++; } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can see measureRight() yields the result, and measureWrong() fires * the assert at the end of the run. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -ea -jar target/benchmarks.jar JMHSample_05 -f 1 * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_05_StateFixtures.class.getSimpleName()) .forks(1) .jvmArgs("-ea") .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_06_FixtureLevel.java000066400000000000000000000100231446271450100311670ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; @State(Scope.Thread) public class JMHSample_06_FixtureLevel { double x; /* * Fixture methods have different levels to control when they should be run. * There are at least three Levels available to the user. These are, from * top to bottom: * * Level.Trial: before or after the entire benchmark run (the sequence of iterations) * Level.Iteration: before or after the benchmark iteration (the sequence of invocations) * Level.Invocation; before or after the benchmark method invocation (WARNING: read the Javadoc before using) * * Time spent in fixture methods does not count into the performance * metrics, so you can use this to do some heavy-lifting. */ @TearDown(Level.Iteration) public void check() { assert x > Math.PI : "Nothing changed?"; } @Benchmark public void measureRight() { x++; } @Benchmark public void measureWrong() { double x = 0; x++; } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can see measureRight() yields the result, and measureWrong() fires * the assert at the end of first iteration! This will not generate the results * for measureWrong(). You can also prevent JMH for proceeding further by * requiring "fail on error". * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -ea -jar target/benchmarks.jar JMHSample_06 -f 1 * (we requested single fork; there are also other options, see -h) * * You can optionally supply -foe to fail the complete run. * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_06_FixtureLevel.class.getSimpleName()) .forks(1) .jvmArgs("-ea") .shouldFailOnError(false) // switch to "true" to fail the complete run .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java000066400000000000000000000131101446271450100332220ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.*; /** * Fixtures have different Levels to control when they are about to run. * Level.Invocation is useful sometimes to do some per-invocation work * which should not count as payload (e.g. sleep for some time to emulate * think time) */ @OutputTimeUnit(TimeUnit.MICROSECONDS) public class JMHSample_07_FixtureLevelInvocation { /* * Fixtures have different Levels to control when they are about to run. * Level.Invocation is useful sometimes to do some per-invocation work, * which should not count as payload. PLEASE NOTE the timestamping and * synchronization for Level.Invocation helpers might significantly offset * the measurement, use with care. See Level.Invocation javadoc for further * discussion. * * Consider this sample: */ /* * This state handles the executor. * Note we create and shutdown executor with Level.Trial, so * it is kept around the same across all iterations. */ @State(Scope.Benchmark) public static class NormalState { ExecutorService service; @Setup(Level.Trial) public void up() { service = Executors.newCachedThreadPool(); } @TearDown(Level.Trial) public void down() { service.shutdown(); } } /* * This is the *extension* of the basic state, which also * has the Level.Invocation fixture method, sleeping for some time. */ public static class LaggingState extends NormalState { public static final int SLEEP_TIME = Integer.getInteger("sleepTime", 10); @Setup(Level.Invocation) public void lag() throws InterruptedException { TimeUnit.MILLISECONDS.sleep(SLEEP_TIME); } } /* * This allows us to formulate the task: measure the task turnaround in * "hot" mode when we are not sleeping between the submits, and "cold" mode, * when we are sleeping. */ @Benchmark @BenchmarkMode(Mode.AverageTime) public double measureHot(NormalState e, final Scratch s) throws ExecutionException, InterruptedException { return e.service.submit(new Task(s)).get(); } @Benchmark @BenchmarkMode(Mode.AverageTime) public double measureCold(LaggingState e, final Scratch s) throws ExecutionException, InterruptedException { return e.service.submit(new Task(s)).get(); } /* * This is our scratch state which will handle the work. */ @State(Scope.Thread) public static class Scratch { private double p; public double doWork() { p = Math.log(p); return p; } } public static class Task implements Callable { private Scratch s; public Task(Scratch s) { this.s = s; } @Override public Double call() { return s.doWork(); } } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can see the cold scenario is running longer, because we pay for * thread wakeups. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_07 -f 1 * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_07_FixtureLevelInvocation.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java000066400000000000000000000100321446271450100302030ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class JMHSample_08_DeadCode { /* * The downfall of many benchmarks is Dead-Code Elimination (DCE): compilers * are smart enough to deduce some computations are redundant and eliminate * them completely. If the eliminated part was our benchmarked code, we are * in trouble. * * Fortunately, JMH provides the essential infrastructure to fight this * where appropriate: returning the result of the computation will ask JMH * to deal with the result to limit dead-code elimination (returned results * are implicitly consumed by Blackholes, see JMHSample_09_Blackholes). */ private double x = Math.PI; private double compute(double d) { for (int c = 0; c < 10; c++) { d = d * d / Math.PI; } return d; } @Benchmark public void baseline() { // do nothing, this is a baseline } @Benchmark public void measureWrong() { // This is wrong: result is not used and the entire computation is optimized away. compute(x); } @Benchmark public double measureRight() { // This is correct: the result is being used. return compute(x); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can see the unrealistically fast calculation in with measureWrong(), * while realistic measurement with measureRight(). * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_08 -f 1 * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_08_DeadCode.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java000066400000000000000000000110471446271450100306320ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) public class JMHSample_09_Blackholes { /* * Should your benchmark require returning multiple results, you have to * consider two options (detailed below). * * NOTE: If you are only producing a single result, it is more readable to * use the implicit return, as in JMHSample_08_DeadCode. Do not make your benchmark * code less readable with explicit Blackholes! */ double x1 = Math.PI; double x2 = Math.PI * 2; private double compute(double d) { for (int c = 0; c < 10; c++) { d = d * d / Math.PI; } return d; } /* * Baseline measurement: how much a single compute() costs. */ @Benchmark public double baseline() { return compute(x1); } /* * While the compute(x2) computation is intact, compute(x1) * is redundant and optimized out. */ @Benchmark public double measureWrong() { compute(x1); return compute(x2); } /* * This demonstrates Option A: * * Merge multiple results into one and return it. * This is OK when is computation is relatively heavyweight, and merging * the results does not offset the results much. */ @Benchmark public double measureRight_1() { return compute(x1) + compute(x2); } /* * This demonstrates Option B: * * Use explicit Blackhole objects, and sink the values there. * (Background: Blackhole is just another @State object, bundled with JMH). */ @Benchmark public void measureRight_2(Blackhole bh) { bh.consume(compute(x1)); bh.consume(compute(x2)); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You will see measureWrong() running on-par with baseline(). * Both measureRight() are measuring twice the baseline, so the logs are intact. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_09 -f 1 * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_09_Blackholes.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java000066400000000000000000000111431446271450100311460ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class JMHSample_10_ConstantFold { /* * The flip side of dead-code elimination is constant-folding. * * If JVM realizes the result of the computation is the same no matter what, * it can cleverly optimize it. In our case, that means we can move the * computation outside of the internal JMH loop. * * This can be prevented by always reading the inputs from non-final * instance fields of @State objects, computing the result based on those * values, and follow the rules to prevent DCE. */ // IDEs will say "Oh, you can convert this field to local variable". Don't. Trust. Them. // (While this is normally fine advice, it does not work in the context of measuring correctly.) private double x = Math.PI; // IDEs will probably also say "Look, it could be final". Don't. Trust. Them. Either. // (While this is normally fine advice, it does not work in the context of measuring correctly.) private final double wrongX = Math.PI; private double compute(double d) { for (int c = 0; c < 10; c++) { d = d * d / Math.PI; } return d; } @Benchmark public double baseline() { // simply return the value, this is a baseline return Math.PI; } @Benchmark public double measureWrong_1() { // This is wrong: the source is predictable, and computation is foldable. return compute(Math.PI); } @Benchmark public double measureWrong_2() { // This is wrong: the source is predictable, and computation is foldable. return compute(wrongX); } @Benchmark public double measureRight() { // This is correct: the source is not predictable. return compute(x); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can see the unrealistically fast calculation in with measureWrong_*(), * while realistic measurement with measureRight(). * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_10 -i 5 -f 1 * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_10_ConstantFold.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java000066400000000000000000000120711446271450100276460ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class JMHSample_11_Loops { /* * It would be tempting for users to do loops within the benchmarked method. * (This is the bad thing Caliper taught everyone). These tests explain why * this is a bad idea. * * Looping is done in the hope of minimizing the overhead of calling the * test method, by doing the operations inside the loop instead of inside * the method call. Don't buy this argument; you will see there is more * magic happening when we allow optimizers to merge the loop iterations. */ /* * Suppose we want to measure how much it takes to sum two integers: */ int x = 1; int y = 2; /* * This is what you do with JMH. */ @Benchmark public int measureRight() { return (x + y); } /* * The following tests emulate the naive looping. * This is the Caliper-style benchmark. */ private int reps(int reps) { int s = 0; for (int i = 0; i < reps; i++) { s += (x + y); } return s; } /* * We would like to measure this with different repetitions count. * Special annotation is used to get the individual operation cost. */ @Benchmark @OperationsPerInvocation(1) public int measureWrong_1() { return reps(1); } @Benchmark @OperationsPerInvocation(10) public int measureWrong_10() { return reps(10); } @Benchmark @OperationsPerInvocation(100) public int measureWrong_100() { return reps(100); } @Benchmark @OperationsPerInvocation(1_000) public int measureWrong_1000() { return reps(1_000); } @Benchmark @OperationsPerInvocation(10_000) public int measureWrong_10000() { return reps(10_000); } @Benchmark @OperationsPerInvocation(100_000) public int measureWrong_100000() { return reps(100_000); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You might notice the larger the repetitions count, the lower the "perceived" * cost of the operation being measured. Up to the point we do each addition with 1/20 ns, * well beyond what hardware can actually do. * * This happens because the loop is heavily unrolled/pipelined, and the operation * to be measured is hoisted from the loop. Moral: don't overuse loops, rely on JMH * to get the measurement right. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_11 -f 1 * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_11_Loops.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java000066400000000000000000000124701446271450100301550ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class JMHSample_12_Forking { /* * JVMs are notoriously good at profile-guided optimizations. This is bad * for benchmarks, because different tests can mix their profiles together, * and then render the "uniformly bad" code for every test. Forking (running * in a separate process) each test can help to evade this issue. * * JMH will fork the tests by default. */ /* * Suppose we have this simple counter interface, and two implementations. * Even though those are semantically the same, from the JVM standpoint, * those are distinct classes. */ public interface Counter { int inc(); } public static class Counter1 implements Counter { private int x; @Override public int inc() { return x++; } } public static class Counter2 implements Counter { private int x; @Override public int inc() { return x++; } } /* * And this is how we measure it. * Note this is susceptible for same issue with loops we mention in previous examples. */ public int measure(Counter c) { int s = 0; for (int i = 0; i < 10; i++) { s += c.inc(); } return s; } /* * These are two counters. */ Counter c1 = new Counter1(); Counter c2 = new Counter2(); /* * We first measure the Counter1 alone... * Fork(0) helps to run in the same JVM. */ @Benchmark @Fork(0) public int measure_1_c1() { return measure(c1); } /* * Then Counter2... */ @Benchmark @Fork(0) public int measure_2_c2() { return measure(c2); } /* * Then Counter1 again... */ @Benchmark @Fork(0) public int measure_3_c1_again() { return measure(c1); } /* * These two tests have explicit @Fork annotation. * JMH takes this annotation as the request to run the test in the forked JVM. * It's even simpler to force this behavior for all the tests via the command * line option "-f". The forking is default, but we still use the annotation * for the consistency. * * This is the test for Counter1. */ @Benchmark @Fork(1) public int measure_4_forked_c1() { return measure(c1); } /* * ...and this is the test for Counter2. */ @Benchmark @Fork(1) public int measure_5_forked_c2() { return measure(c2); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * Note that C1 is faster, C2 is slower, but the C1 is slow again! This is because * the profiles for C1 and C2 had merged together. Notice how flawless the measurement * is for forked runs. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_12 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_12_Forking.class.getSimpleName()) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java000066400000000000000000000112011446271450100303020ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) public class JMHSample_13_RunToRun { /* * Forking also allows to estimate run-to-run variance. * * JVMs are complex systems, and the non-determinism is inherent for them. * This requires us to always account the run-to-run variance as the one * of the effects in our experiments. * * Luckily, forking aggregates the results across several JVM launches. */ /* * In order to introduce readily measurable run-to-run variance, we build * the workload which performance differs from run to run. Note that many workloads * will have the similar behavior, but we do that artificially to make a point. */ @State(Scope.Thread) public static class SleepyState { public long sleepTime; @Setup public void setup() { sleepTime = (long) (Math.random() * 1000); } } /* * Now, we will run this different number of times. */ @Benchmark @Fork(1) public void baseline(SleepyState s) throws InterruptedException { TimeUnit.MILLISECONDS.sleep(s.sleepTime); } @Benchmark @Fork(5) public void fork_1(SleepyState s) throws InterruptedException { TimeUnit.MILLISECONDS.sleep(s.sleepTime); } @Benchmark @Fork(20) public void fork_2(SleepyState s) throws InterruptedException { TimeUnit.MILLISECONDS.sleep(s.sleepTime); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * Note the baseline is random within [0..1000] msec; and both forked runs * are estimating the average 500 msec with some confidence. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_13 -wi 0 -i 3 * (we requested no warmup, 3 measurement iterations; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_13_RunToRun.class.getSimpleName()) .warmupIterations(0) .measurementIterations(3) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java000066400000000000000000000122111446271450100306670ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.GroupThreads; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Group) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class JMHSample_15_Asymmetric { /* * So far all the tests were symmetric: the same code was executed in all the threads. * At times, you need the asymmetric test. JMH provides this with the notion of @Group, * which can bind several methods together, and all the threads are distributed among * the test methods. * * Each execution group contains of one or more threads. Each thread within a particular * execution group executes one of @Group-annotated @Benchmark methods. Multiple execution * groups may participate in the run. The total thread count in the run is rounded to the * execution group size, which will only allow the full execution groups. * * Note that two state scopes: Scope.Benchmark and Scope.Thread are not covering all * the use cases here -- you either share everything in the state, or share nothing. * To break this, we have the middle ground Scope.Group, which marks the state to be * shared within the execution group, but not among the execution groups. * * Putting this all together, the example below means: * a) define the execution group "g", with 3 threads executing inc(), and 1 thread * executing get(), 4 threads per group in total; * b) if we run this test case with 4 threads, then we will have a single execution * group. Generally, running with 4*N threads will create N execution groups, etc.; * c) each execution group has one @State instance to share: that is, execution groups * share the counter within the group, but not across the groups. */ private AtomicInteger counter; @Setup public void up() { counter = new AtomicInteger(); } @Benchmark @Group("g") @GroupThreads(3) public int inc() { return counter.incrementAndGet(); } @Benchmark @Group("g") @GroupThreads(1) public int get() { return counter.get(); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You will have the distinct metrics for inc() and get() from this run. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_15 -f 1 * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_15_Asymmetric.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java000066400000000000000000000116471446271450100317020ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class JMHSample_16_CompilerControl { /* * We can use HotSpot-specific functionality to tell the compiler what * do we want to do with particular methods. To demonstrate the effects, * we end up with 3 methods in this sample. */ /** * These are our targets: * - first method is prohibited from inlining * - second method is forced to inline * - third method is prohibited from compiling * * We might even place the annotations directly to the benchmarked * methods, but this expresses the intent more clearly. */ public void target_blank() { // this method was intentionally left blank } @CompilerControl(CompilerControl.Mode.DONT_INLINE) public void target_dontInline() { // this method was intentionally left blank } @CompilerControl(CompilerControl.Mode.INLINE) public void target_inline() { // this method was intentionally left blank } @CompilerControl(CompilerControl.Mode.EXCLUDE) public void target_exclude() { // this method was intentionally left blank } /* * These method measures the calls performance. */ @Benchmark public void baseline() { // this method was intentionally left blank } @Benchmark public void blank() { target_blank(); } @Benchmark public void dontinline() { target_dontInline(); } @Benchmark public void inline() { target_inline(); } @Benchmark public void exclude() { target_exclude(); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * Note the performance of the baseline, blank, and inline methods are the same. * dontinline differs a bit, because we are making the proper call. * exclude is severely slower, becase we are not compiling it at all. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_16 -wi 0 -i 3 -f 1 * (we requested no warmup iterations, 3 iterations, single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_16_CompilerControl.class.getSimpleName()) .warmupIterations(0) .measurementIterations(3) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java000066400000000000000000000117031446271450100315370ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @OutputTimeUnit(TimeUnit.MILLISECONDS) public class JMHSample_17_SyncIterations { /* * This is the another thing that is enabled in JMH by default. * * Suppose we have this simple benchmark. */ private double src; @Benchmark public double test() { double s = src; for (int i = 0; i < 1000; i++) { s = Math.sin(s); } return s; } /* * It turns out if you run the benchmark with multiple threads, * the way you start and stop the worker threads seriously affects * performance. * * The natural way would be to park all the threads on some sort * of barrier, and the let them go "at once". However, that does * not work: there are no guarantees the worker threads will start * at the same time, meaning other worker threads are working * in better conditions, skewing the result. * * The better solution would be to introduce bogus iterations, * ramp up the threads executing the iterations, and then atomically * shift the system to measuring stuff. The same thing can be done * during the rampdown. This sounds complicated, but JMH already * handles that for you. * */ /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You will need to oversubscribe the system to make this effect * clearly visible; however, this effect can also be shown on the * unsaturated systems.* * * Note the performance of -si false version is more flaky, even * though it is "better". This is the false improvement, granted by * some of the threads executing in solo. The -si true version more stable * and coherent. * * -si true is enabled by default. * * Say, $CPU is the number of CPUs on your machine. * * You can run this test with: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_17 \ * -w 1s -r 1s -f 1 -t ${CPU*16} -si {true|false} * (we requested shorter warmup/measurement iterations, single fork, * lots of threads, and changeable "synchronize iterations" option) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_17_SyncIterations.class.getSimpleName()) .warmupTime(TimeValue.seconds(1)) .measurementTime(TimeValue.seconds(1)) .threads(Runtime.getRuntime().availableProcessors()*16) .forks(1) .syncIterations(true) // try to switch to "false" .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_18_Control.java000066400000000000000000000077261446271450100302140ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.Control; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.atomic.AtomicBoolean; @State(Scope.Group) public class JMHSample_18_Control { /* * Sometimes you need the tap into the harness mind to get the info * on the transition change. For this, we have the experimental state object, * Control, which is updated by JMH as we go. */ /* * In this example, we want to estimate the ping-pong speed for the simple * AtomicBoolean. Unfortunately, doing that in naive manner will livelock * one of the threads, because the executions of ping/pong are not paired * perfectly. We need the escape hatch to terminate the loop if threads * are about to leave the measurement. */ public final AtomicBoolean flag = new AtomicBoolean(); @Benchmark @Group("pingpong") public void ping(Control cnt) { while (!cnt.stopMeasurement && !flag.compareAndSet(false, true)) { // this body is intentionally left blank } } @Benchmark @Group("pingpong") public void pong(Control cnt) { while (!cnt.stopMeasurement && !flag.compareAndSet(true, false)) { // this body is intentionally left blank } } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_18 -t 2 -f 1 * (we requested 2 threads and single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_18_Control.class.getSimpleName()) .threads(2) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_20_Annotations.java000066400000000000000000000076061446271450100310570ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Fork(1) public class JMHSample_20_Annotations { double x1 = Math.PI; /* * In addition to all the command line options usable at run time, * we have the annotations which can provide the reasonable defaults * for the some of the benchmarks. This is very useful when you are * dealing with lots of benchmarks, and some of them require * special treatment. * * Annotation can also be placed on class, to have the effect over * all the benchmark methods in the same class. The rule is, the * annotation in the closest scope takes the precedence: i.e. * the method-based annotation overrides class-based annotation, * etc. */ @Benchmark @Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) public double measure() { return Math.log(x1); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * Note JMH honors the default annotation settings. You can always override * the defaults via the command line or API. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_20 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_20_Annotations.class.getSimpleName()) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java000066400000000000000000000111511446271450100305320ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class JMHSample_21_ConsumeCPU { /* * At times you require the test to burn some of the cycles doing nothing. * In many cases, you *do* want to burn the cycles instead of waiting. * * For these occasions, we have the infrastructure support. Blackholes * can not only consume the values, but also the time! Run this test * to get familiar with this part of JMH. * * (Note we use static method because most of the use cases are deep * within the testing code, and propagating blackholes is tedious). */ @Benchmark public void consume_0000() { Blackhole.consumeCPU(0); } @Benchmark public void consume_0001() { Blackhole.consumeCPU(1); } @Benchmark public void consume_0002() { Blackhole.consumeCPU(2); } @Benchmark public void consume_0004() { Blackhole.consumeCPU(4); } @Benchmark public void consume_0008() { Blackhole.consumeCPU(8); } @Benchmark public void consume_0016() { Blackhole.consumeCPU(16); } @Benchmark public void consume_0032() { Blackhole.consumeCPU(32); } @Benchmark public void consume_0064() { Blackhole.consumeCPU(64); } @Benchmark public void consume_0128() { Blackhole.consumeCPU(128); } @Benchmark public void consume_0256() { Blackhole.consumeCPU(256); } @Benchmark public void consume_0512() { Blackhole.consumeCPU(512); } @Benchmark public void consume_1024() { Blackhole.consumeCPU(1024); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * Note the single token is just a few cycles, and the more tokens * you request, then more work is spent (almost linearly) * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_21 -f 1 * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_21_ConsumeCPU.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_22_FalseSharing.java000066400000000000000000000205721446271450100311270ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(5) public class JMHSample_22_FalseSharing { /* * One of the unusual thing that can bite you back is false sharing. * If two threads access (and possibly modify) the adjacent values * in memory, chances are, they are modifying the values on the same * cache line. This can yield significant (artificial) slowdowns. * * JMH helps you to alleviate this: @States are automatically padded. * This padding does not extend to the State internals though, * as we will see in this example. You have to take care of this on * your own. */ /* * Suppose we have two threads: * a) innocuous reader which blindly reads its own field * b) furious writer which updates its own field */ /* * BASELINE EXPERIMENT: * Because of the false sharing, both reader and writer will experience * penalties. */ @State(Scope.Group) public static class StateBaseline { int readOnly; int writeOnly; } @Benchmark @Group("baseline") public int reader(StateBaseline s) { return s.readOnly; } @Benchmark @Group("baseline") public void writer(StateBaseline s) { s.writeOnly++; } /* * APPROACH 1: PADDING * * We can try to alleviate some of the effects with padding. * This is not versatile because JVMs can freely rearrange the * field order, even of the same type. */ @State(Scope.Group) public static class StatePadded { int readOnly; int p01, p02, p03, p04, p05, p06, p07, p08; int p11, p12, p13, p14, p15, p16, p17, p18; int writeOnly; int q01, q02, q03, q04, q05, q06, q07, q08; int q11, q12, q13, q14, q15, q16, q17, q18; } @Benchmark @Group("padded") public int reader(StatePadded s) { return s.readOnly; } @Benchmark @Group("padded") public void writer(StatePadded s) { s.writeOnly++; } /* * APPROACH 2: CLASS HIERARCHY TRICK * * We can alleviate false sharing with this convoluted hierarchy trick, * using the fact that superclass fields are usually laid out first. * In this construction, the protected field will be squashed between * paddings. * It is important to use the smallest data type, so that layouter would * not generate any gaps that can be taken by later protected subclasses * fields. Depending on the actual field layout of classes that bear the * protected fields, we might need more padding to account for "lost" * padding fields pulled into in their superclass gaps. */ public static class StateHierarchy_1 { int readOnly; } public static class StateHierarchy_2 extends StateHierarchy_1 { byte p01, p02, p03, p04, p05, p06, p07, p08; byte p11, p12, p13, p14, p15, p16, p17, p18; byte p21, p22, p23, p24, p25, p26, p27, p28; byte p31, p32, p33, p34, p35, p36, p37, p38; byte p41, p42, p43, p44, p45, p46, p47, p48; byte p51, p52, p53, p54, p55, p56, p57, p58; byte p61, p62, p63, p64, p65, p66, p67, p68; byte p71, p72, p73, p74, p75, p76, p77, p78; } public static class StateHierarchy_3 extends StateHierarchy_2 { int writeOnly; } public static class StateHierarchy_4 extends StateHierarchy_3 { byte q01, q02, q03, q04, q05, q06, q07, q08; byte q11, q12, q13, q14, q15, q16, q17, q18; byte q21, q22, q23, q24, q25, q26, q27, q28; byte q31, q32, q33, q34, q35, q36, q37, q38; byte q41, q42, q43, q44, q45, q46, q47, q48; byte q51, q52, q53, q54, q55, q56, q57, q58; byte q61, q62, q63, q64, q65, q66, q67, q68; byte q71, q72, q73, q74, q75, q76, q77, q78; } @State(Scope.Group) public static class StateHierarchy extends StateHierarchy_4 { } @Benchmark @Group("hierarchy") public int reader(StateHierarchy s) { return s.readOnly; } @Benchmark @Group("hierarchy") public void writer(StateHierarchy s) { s.writeOnly++; } /* * APPROACH 3: ARRAY TRICK * * This trick relies on the contiguous allocation of an array. * Instead of placing the fields in the class, we mangle them * into the array at very sparse offsets. */ @State(Scope.Group) public static class StateArray { int[] arr = new int[128]; } @Benchmark @Group("sparse") public int reader(StateArray s) { return s.arr[0]; } @Benchmark @Group("sparse") public void writer(StateArray s) { s.arr[64]++; } /* * APPROACH 4: * * @Contended (since JDK 8): * Uncomment the annotation if building with JDK 8. * Remember to flip -XX:-RestrictContended to enable. */ @State(Scope.Group) public static class StateContended { int readOnly; // @sun.misc.Contended int writeOnly; } @Benchmark @Group("contended") public int reader(StateContended s) { return s.readOnly; } @Benchmark @Group("contended") public void writer(StateContended s) { s.writeOnly++; } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * Note the slowdowns. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_22 -t $CPU * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_22_FalseSharing.class.getSimpleName()) .threads(Runtime.getRuntime().availableProcessors()) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_23_AuxCounters.java000066400000000000000000000112501446271450100310330ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @OutputTimeUnit(TimeUnit.SECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) public class JMHSample_23_AuxCounters { /* * In some weird cases you need to get the separate throughput/time * metrics for the benchmarked code depending on the outcome of the * current code. Trying to accommodate the cases like this, JMH optionally * provides the special annotation which treats @State objects * as the object bearing user counters. See @AuxCounters javadoc for * the limitations. */ @State(Scope.Thread) @AuxCounters(AuxCounters.Type.OPERATIONS) public static class OpCounters { // These fields would be counted as metrics public int case1; public int case2; // This accessor will also produce a metric public int total() { return case1 + case2; } } @State(Scope.Thread) @AuxCounters(AuxCounters.Type.EVENTS) public static class EventCounters { // This field would be counted as metric public int wows; } /* * This code measures the "throughput" in two parts of the branch. * The @AuxCounters state above holds the counters which we increment * ourselves, and then let JMH to use their values in the performance * calculations. */ @Benchmark public void splitBranch(OpCounters counters) { if (Math.random() < 0.1) { counters.case1++; } else { counters.case2++; } } @Benchmark public void runSETI(EventCounters counters) { float random = (float) Math.random(); float wowSignal = (float) Math.PI / 4; if (random == wowSignal) { // WOW, that's unusual. counters.wows++; } } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_23 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_23_AuxCounters.class.getSimpleName()) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_24_Inheritance.java000066400000000000000000000115541446271450100310140ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; public class JMHSample_24_Inheritance { /* * In very special circumstances, you might want to provide the benchmark * body in the (abstract) superclass, and specialize it with the concrete * pieces in the subclasses. * * The rule of thumb is: if some class has @Benchmark method, then all the subclasses * are also having the "synthetic" @Benchmark method. The caveat is, because we only * know the type hierarchy during the compilation, it is only possible during * the same compilation session. That is, mixing in the subclass extending your * benchmark class *after* the JMH compilation would have no effect. * * Note how annotations now have two possible places. The closest annotation * in the hierarchy wins. */ @BenchmarkMode(Mode.AverageTime) @Fork(1) @State(Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) public static abstract class AbstractBenchmark { int x; @Setup public void setup() { x = 42; } @Benchmark @Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) public double bench() { return doWork() * doWork(); } protected abstract double doWork(); } public static class BenchmarkLog extends AbstractBenchmark { @Override protected double doWork() { return Math.log(x); } } public static class BenchmarkSin extends AbstractBenchmark { @Override protected double doWork() { return Math.sin(x); } } public static class BenchmarkCos extends AbstractBenchmark { @Override protected double doWork() { return Math.cos(x); } } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test, and observe the three distinct benchmarks running the squares * of Math.log, Math.sin, and Math.cos, accordingly. * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_24 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_24_Inheritance.class.getSimpleName()) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java000066400000000000000000000275451446271450100275530ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; import java.util.ArrayList; import java.util.Collections; import java.util.List; @State(Scope.Thread) public class JMHSample_25_API_GA { /** * This example shows the rather convoluted, but fun way to exploit * JMH API in complex scenarios. Up to this point, we haven't consumed * the results programmatically, and hence we are missing all the fun. * * Let's consider this naive code, which obviously suffers from the * performance anomalies, since current HotSpot is resistant to make * the tail-call optimizations. */ private int v; @Benchmark public int test() { return veryImportantCode(1000, v); } public int veryImportantCode(int d, int v) { if (d == 0) { return v; } else { return veryImportantCode(d - 1, v); } } /* * We could probably make up for the absence of TCO with better inlining * policy. But hand-tuning the policy requires knowing a lot about VM * internals. Let's instead construct the layman's genetic algorithm * which sifts through inlining settings trying to find the better policy. * * If you are not familiar with the concept of Genetic Algorithms, * read the Wikipedia article first: * http://en.wikipedia.org/wiki/Genetic_algorithm * * VM experts can guess which option should be tuned to get the max * performance. Try to run the sample and see if it improves performance. */ public static void main(String[] args) throws RunnerException { // These are our base options. We will mix these options into the // measurement runs. That is, all measurement runs will inherit these, // see how it's done below. Options baseOpts = new OptionsBuilder() .include(JMHSample_25_API_GA.class.getName()) .warmupTime(TimeValue.milliseconds(200)) .measurementTime(TimeValue.milliseconds(200)) .warmupIterations(5) .measurementIterations(5) .forks(1) .verbosity(VerboseMode.SILENT) .build(); // Initial population Population pop = new Population(); final int POPULATION = 10; for (int c = 0; c < POPULATION; c++) { pop.addChromosome(new Chromosome(baseOpts)); } // Make a few rounds of optimization: final int GENERATIONS = 100; for (int g = 0; g < GENERATIONS; g++) { System.out.println("Entering generation " + g); // Get the baseline score. // We opt to remeasure it in order to get reliable current estimate. RunResult runner = new Runner(baseOpts).runSingle(); Result baseResult = runner.getPrimaryResult(); // Printing a nice table... System.out.println("---------------------------------------"); System.out.printf("Baseline score: %10.2f %s%n", baseResult.getScore(), baseResult.getScoreUnit() ); for (Chromosome c : pop.getAll()) { System.out.printf("%10.2f %s (%+10.2f%%) %s%n", c.getScore(), baseResult.getScoreUnit(), (c.getScore() / baseResult.getScore() - 1) * 100, c.toString() ); } System.out.println(); Population newPop = new Population(); // Copy out elite solutions final int ELITE = 2; for (Chromosome c : pop.getAll().subList(0, ELITE)) { newPop.addChromosome(c); } // Cross-breed the rest of new population while (newPop.size() < pop.size()) { Chromosome p1 = pop.selectToBreed(); Chromosome p2 = pop.selectToBreed(); newPop.addChromosome(p1.crossover(p2).mutate()); newPop.addChromosome(p2.crossover(p1).mutate()); } pop = newPop; } } /** * Population. */ public static class Population { private final List list = new ArrayList<>(); public void addChromosome(Chromosome c) { list.add(c); Collections.sort(list); } /** * Select the breeding material. * Solutions with better score have better chance to be selected. * @return breed */ public Chromosome selectToBreed() { double totalScore = 0D; for (Chromosome c : list) { totalScore += c.score(); } double thresh = Math.random() * totalScore; for (Chromosome c : list) { if (thresh >= 0) { thresh -= c.score(); } else { return c; } } // Return the last return list.get(list.size() - 1); } public int size() { return list.size(); } public List getAll() { return list; } } /** * Chromosome: encodes solution. */ public static class Chromosome implements Comparable { // Current score is not yet computed. double score = Double.NEGATIVE_INFINITY; // Base options to mix in final Options baseOpts; // These are current HotSpot defaults. int freqInlineSize = 325; int inlineSmallCode = 1000; int maxInlineLevel = 9; int maxInlineSize = 35; int maxRecursiveInlineLevel = 1; int minInliningThreshold = 250; public Chromosome(Options baseOpts) { this.baseOpts = baseOpts; } public double score() { if (score != Double.NEGATIVE_INFINITY) { // Already got the score, shortcutting return score; } try { // Add the options encoded by this solution: // a) Mix in base options. // b) Add JVM arguments: we opt to parse the // stringly representation to make the example // shorter. There are, of course, cleaner ways // to do this. Options theseOpts = new OptionsBuilder() .parent(baseOpts) .jvmArgs(toString().split("[ ]")) .build(); // Run through JMH and get the result back. RunResult runResult = new Runner(theseOpts).runSingle(); score = runResult.getPrimaryResult().getScore(); } catch (RunnerException e) { // Something went wrong, the solution is defective score = Double.MIN_VALUE; } return score; } @Override public int compareTo(Chromosome o) { // Order by score, descending. return -Double.compare(score(), o.score()); } @Override public String toString() { return "-XX:FreqInlineSize=" + freqInlineSize + " -XX:InlineSmallCode=" + inlineSmallCode + " -XX:MaxInlineLevel=" + maxInlineLevel + " -XX:MaxInlineSize=" + maxInlineSize + " -XX:MaxRecursiveInlineLevel=" + maxRecursiveInlineLevel + " -XX:MinInliningThreshold=" + minInliningThreshold; } public Chromosome crossover(Chromosome other) { // Perform crossover: // While this is a very naive way to perform crossover, it still works. final double CROSSOVER_PROB = 0.1; Chromosome result = new Chromosome(baseOpts); result.freqInlineSize = (Math.random() < CROSSOVER_PROB) ? this.freqInlineSize : other.freqInlineSize; result.inlineSmallCode = (Math.random() < CROSSOVER_PROB) ? this.inlineSmallCode : other.inlineSmallCode; result.maxInlineLevel = (Math.random() < CROSSOVER_PROB) ? this.maxInlineLevel : other.maxInlineLevel; result.maxInlineSize = (Math.random() < CROSSOVER_PROB) ? this.maxInlineSize : other.maxInlineSize; result.maxRecursiveInlineLevel = (Math.random() < CROSSOVER_PROB) ? this.maxRecursiveInlineLevel : other.maxRecursiveInlineLevel; result.minInliningThreshold = (Math.random() < CROSSOVER_PROB) ? this.minInliningThreshold : other.minInliningThreshold; return result; } public Chromosome mutate() { // Perform mutation: // Again, this is a naive way to do mutation, but it still works. Chromosome result = new Chromosome(baseOpts); result.freqInlineSize = (int) randomChange(freqInlineSize); result.inlineSmallCode = (int) randomChange(inlineSmallCode); result.maxInlineLevel = (int) randomChange(maxInlineLevel); result.maxInlineSize = (int) randomChange(maxInlineSize); result.maxRecursiveInlineLevel = (int) randomChange(maxRecursiveInlineLevel); result.minInliningThreshold = (int) randomChange(minInliningThreshold); return result; } private double randomChange(double v) { final double MUTATE_PROB = 0.5; if (Math.random() < MUTATE_PROB) { if (Math.random() < 0.5) { return v / (Math.random() * 2); } else { return v * (Math.random() * 2); } } else { return v; } } public double getScore() { return score; } } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_26_BatchSize.java000066400000000000000000000123051446271450100304340ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.LinkedList; import java.util.List; @State(Scope.Thread) public class JMHSample_26_BatchSize { /* * Sometimes you need to evaluate operation which doesn't have * the steady state. The cost of a benchmarked operation may * significantly vary from invocation to invocation. * * In this case, using the timed measurements is not a good idea, * and the only acceptable benchmark mode is a single shot. On the * other hand, the operation may be too small for reliable single * shot measurement. * * We can use "batch size" parameter to describe the number of * @Benchmark invocations to do per one "shot" without looping the method * manually and protect from problems described in JMHSample_11_Loops. * If there are any @Setup/@TearDown(Level.Invocation), they still run * per each @Benchmark invocation. */ /* * Suppose we want to measure insertion in the middle of the list. */ List list = new LinkedList<>(); @Benchmark @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) @BenchmarkMode(Mode.AverageTime) public List measureWrong_1() { list.add(list.size() / 2, "something"); return list; } @Benchmark @Warmup(iterations = 5, time = 5) @Measurement(iterations = 5, time = 5) @BenchmarkMode(Mode.AverageTime) public List measureWrong_5() { list.add(list.size() / 2, "something"); return list; } /* * This is what you do with JMH. */ @Benchmark @Warmup(iterations = 5, batchSize = 5000) @Measurement(iterations = 5, batchSize = 5000) @BenchmarkMode(Mode.SingleShotTime) public List measureRight() { list.add(list.size() / 2, "something"); return list; } @Setup(Level.Iteration) public void setup(){ list.clear(); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can see completely different results for measureWrong_1 and measureWrong_5; this * is because the workload has no steady state. The result of the workload is dependent * on the measurement time. measureRight does not have this drawback, because it measures * the N invocations of the test method and measures it's time. * * We measure batch of 5000 invocations and consider the batch as the single operation. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_26 -f 1 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_26_BatchSize.class.getSimpleName()) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_27_Params.java000066400000000000000000000077251446271450100300160ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.math.BigInteger; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @State(Scope.Benchmark) public class JMHSample_27_Params { /** * In many cases, the experiments require walking the configuration space * for a benchmark. This is needed for additional control, or investigating * how the workload performance changes with different settings. */ @Param({"1", "31", "65", "101", "103"}) public int arg; @Param({"0", "1", "2", "4", "8", "16", "32"}) public int certainty; @Benchmark public boolean bench() { return BigInteger.valueOf(arg).isProbablePrime(certainty); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * Note the performance is different with different parameters. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_27 * * You can juggle parameters through the command line, e.g. with "-p arg=41,42" * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_27_Params.class.getSimpleName()) // .param("arg", "41", "42") // Use this to selectively constrain/override parameters .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_28_BlackholeHelpers.java000066400000000000000000000121121446271450100317650ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @State(Scope.Thread) public class JMHSample_28_BlackholeHelpers { /** * Sometimes you need the black hole not in @Benchmark method, but in * helper methods, because you want to pass it through to the concrete * implementation which is instantiated in helper methods. In this case, * you can request the black hole straight in the helper method signature. * This applies to both @Setup and @TearDown methods, and also to other * JMH infrastructure objects, like Control. * * Below is the variant of {@link org.openjdk.jmh.samples.JMHSample_08_DeadCode} * test, but wrapped in the anonymous classes. */ public interface Worker { void work(); } private Worker workerBaseline; private Worker workerRight; private Worker workerWrong; private double compute(double d) { for (int c = 0; c < 10; c++) { d = d * d / Math.PI; } return d; } @Setup public void setup(final Blackhole bh) { workerBaseline = new Worker() { double x; @Override public void work() { // do nothing } }; workerWrong = new Worker() { double x; @Override public void work() { compute(x); } }; workerRight = new Worker() { double x; @Override public void work() { bh.consume(compute(x)); } }; } @Benchmark public void baseline() { workerBaseline.work(); } @Benchmark public void measureWrong() { workerWrong.work(); } @Benchmark public void measureRight() { workerRight.work(); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You will see measureWrong() running on-par with baseline(). * Both measureRight() are measuring twice the baseline, so the logs are intact. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_28 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_28_BlackholeHelpers.class.getSimpleName()) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_29_StatesDAG.java000066400000000000000000000132611446271450100303440ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @State(Scope.Thread) public class JMHSample_29_StatesDAG { /** * WARNING: * THIS IS AN EXPERIMENTAL FEATURE, BE READY FOR IT BECOME REMOVED WITHOUT NOTICE! */ /** * There are weird cases when the benchmark state is more cleanly described * by the set of @States, and those @States reference each other. JMH allows * linking @States in directed acyclic graphs (DAGs) by referencing @States * in helper method signatures. (Note that {@link org.openjdk.jmh.samples.JMHSample_28_BlackholeHelpers} * is just a special case of that. * * Following the interface for @Benchmark calls, all @Setups for * referenced @State-s are fired before it becomes accessible to current @State. * Similarly, no @TearDown methods are fired for referenced @State before * current @State is done with it. */ /* * This is a model case, and it might not be a good benchmark. * // TODO: Replace it with the benchmark which does something useful. */ public static class Counter { int x; public int inc() { return x++; } public void dispose() { // pretend this is something really useful } } /* * Shared state maintains the set of Counters, and worker threads should * poll their own instances of Counter to work with. However, it should only * be done once, and therefore, Local state caches it after requesting the * counter from Shared state. */ @State(Scope.Benchmark) public static class Shared { List all; Queue available; @Setup public synchronized void setup() { all = new ArrayList<>(); for (int c = 0; c < 10; c++) { all.add(new Counter()); } available = new LinkedList<>(); available.addAll(all); } @TearDown public synchronized void tearDown() { for (Counter c : all) { c.dispose(); } } public synchronized Counter getMine() { return available.poll(); } } @State(Scope.Thread) public static class Local { Counter cnt; @Setup public void setup(Shared shared) { cnt = shared.getMine(); } } @Benchmark public int test(Local local) { return local.cnt.inc(); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_29 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_29_StatesDAG.class.getSimpleName()) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java000066400000000000000000000113371446271450100307360ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Group; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Group) public class JMHSample_30_Interrupts { /* * JMH can also detect when threads are stuck in the benchmarks, and try * to forcefully interrupt the benchmark thread. JMH tries to do that * when it is arguably sure it would not affect the measurement. */ /* * In this example, we want to measure the simple performance characteristics * of the ArrayBlockingQueue. Unfortunately, doing that without a harness * support will deadlock one of the threads, because the executions of * take/put are not paired perfectly. Fortunately for us, both methods react * to interrupts well, and therefore we can rely on JMH to terminate the * measurement for us. JMH will notify users about the interrupt actions * nevertheless, so users can see if those interrupts affected the measurement. * JMH will start issuing interrupts after the default or user-specified timeout * had been reached. * * This is a variant of org.openjdk.jmh.samples.JMHSample_18_Control, but without * the explicit control objects. This example is suitable for the methods which * react to interrupts gracefully. */ private BlockingQueue q; @Setup public void setup() { q = new ArrayBlockingQueue<>(1); } @Group("Q") @Benchmark public Integer take() throws InterruptedException { return q.take(); } @Group("Q") @Benchmark public void put() throws InterruptedException { q.put(42); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_30 -t 2 -f 5 -to 10 * (we requested 2 threads, 5 forks, and 10 sec timeout) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_30_Interrupts.class.getSimpleName()) .threads(2) .forks(5) .timeout(TimeValue.seconds(10)) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java000066400000000000000000000124121446271450100307560ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.ThreadParams; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Benchmark) public class JMHSample_31_InfraParams { /* * There is a way to query JMH about the current running mode. This is * possible with three infrastructure objects we can request to be injected: * - BenchmarkParams: covers the benchmark-global configuration * - IterationParams: covers the current iteration configuration * - ThreadParams: covers the specifics about threading * * Suppose we want to check how the ConcurrentHashMap scales under different * parallelism levels. We can put concurrencyLevel in @Param, but it sometimes * inconvenient if, say, we want it to follow the @Threads count. Here is * how we can query JMH about how many threads was requested for the current run, * and put that into concurrencyLevel argument for CHM constructor. */ static final int THREAD_SLICE = 1000; private ConcurrentHashMap mapSingle; private ConcurrentHashMap mapFollowThreads; @Setup public void setup(BenchmarkParams params) { int capacity = 16 * THREAD_SLICE * params.getThreads(); mapSingle = new ConcurrentHashMap<>(capacity, 0.75f, 1); mapFollowThreads = new ConcurrentHashMap<>(capacity, 0.75f, params.getThreads()); } /* * Here is another neat trick. Generate the distinct set of keys for all threads: */ @State(Scope.Thread) public static class Ids { private List ids; @Setup public void setup(ThreadParams threads) { ids = new ArrayList<>(); for (int c = 0; c < THREAD_SLICE; c++) { ids.add("ID" + (THREAD_SLICE * threads.getThreadIndex() + c)); } } } @Benchmark public void measureDefault(Ids ids) { for (String s : ids.ids) { mapSingle.remove(s); mapSingle.put(s, s); } } @Benchmark public void measureFollowThreads(Ids ids) { for (String s : ids.ids) { mapFollowThreads.remove(s); mapFollowThreads.put(s, s); } } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_31 -t 4 -f 5 * (we requested 4 threads, and 5 forks; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_31_InfraParams.class.getSimpleName()) .threads(4) .forks(5) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java000066400000000000000000000125011446271450100306440ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.WarmupMode; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class JMHSample_32_BulkWarmup { /* * This is an addendum to JMHSample_12_Forking test. * * Sometimes you want an opposite configuration: instead of separating the profiles * for different benchmarks, you want to mix them together to test the worst-case * scenario. * * JMH has a bulk warmup feature for that: it does the warmups for all the tests * first, and then measures them. JMH still forks the JVM for each test, but once the * new JVM has started, all the warmups are being run there, before running the * measurement. This helps to dodge the type profile skews, as each test is still * executed in a different JVM, and we only "mix" the warmup code we want. */ /* * These test classes are borrowed verbatim from JMHSample_12_Forking. */ public interface Counter { int inc(); } public static class Counter1 implements Counter { private int x; @Override public int inc() { return x++; } } public static class Counter2 implements Counter { private int x; @Override public int inc() { return x++; } } Counter c1 = new Counter1(); Counter c2 = new Counter2(); /* * And this is our test payload. Notice we have to break the inlining of the payload, * so that in could not be inlined in either measure_c1() or measure_c2() below, and * specialized for that only call. */ @CompilerControl(CompilerControl.Mode.DONT_INLINE) public int measure(Counter c) { int s = 0; for (int i = 0; i < 10; i++) { s += c.inc(); } return s; } @Benchmark public int measure_c1() { return measure(c1); } @Benchmark public int measure_c2() { return measure(c2); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * Note how JMH runs the warmups first, and only then a given test. Note how JMH re-warmups * the JVM for each test. The scores for C1 and C2 cases are equally bad, compare them to * the scores from JMHSample_12_Forking. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_32 -f 1 -wm BULK * (we requested a single fork, and bulk warmup mode; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_32_BulkWarmup.class.getSimpleName()) // .includeWarmup(...) <-- this may include other benchmarks into warmup .warmupMode(WarmupMode.BULK) // see other WarmupMode.* as well .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_33_SecurityManager.java000066400000000000000000000131311446271450100316560ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.security.NoSuchAlgorithmException; import java.security.Policy; import java.security.URIParameter; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class JMHSample_33_SecurityManager { /* * Some targeted tests may care about SecurityManager being installed. * Since JMH itself needs to do privileged actions, it is not enough * to blindly install the SecurityManager, as JMH infrastructure will fail. */ /* * In this example, we want to measure the performance of System.getProperty * with SecurityManager installed or not. To do this, we have two state classes * with helper methods. One that reads the default JMH security policy (we ship one * with JMH), and installs the security manager; another one that makes sure * the SecurityManager is not installed. * * If you need a restricted security policy for the tests, you are advised to * get /jmh-security-minimal.policy, that contains the minimal permissions * required for JMH benchmark to run, merge the new permissions there, produce new * policy file in a temporary location, and load that policy file instead. * There is also /jmh-security-minimal-runner.policy, that contains the minimal * permissions for the JMH harness to run, if you want to use JVM args to arm * the SecurityManager. */ @State(Scope.Benchmark) public static class SecurityManagerInstalled { @Setup public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException { URI policyFile = JMHSample_33_SecurityManager.class.getResource("/jmh-security.policy").toURI(); Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile))); System.setSecurityManager(new SecurityManager()); } @TearDown public void tearDown() { System.setSecurityManager(null); } } @State(Scope.Benchmark) public static class SecurityManagerEmpty { @Setup public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException { System.setSecurityManager(null); } } @Benchmark public String testWithSM(SecurityManagerInstalled s) throws InterruptedException { return System.getProperty("java.home"); } @Benchmark public String testWithoutSM(SecurityManagerEmpty s) throws InterruptedException { return System.getProperty("java.home"); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_33 -f 1 * (we requested 5 warmup iterations, 5 forks; there are also other options, see -h)) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_33_SecurityManager.class.getSimpleName()) .warmupIterations(5) .measurementIterations(5) .forks(1) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_34_SafeLooping.java000066400000000000000000000165651446271450100310010ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(3) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public class JMHSample_34_SafeLooping { /* * JMHSample_11_Loops warns about the dangers of using loops in @Benchmark methods. * Sometimes, however, one needs to traverse through several elements in a dataset. * This is hard to do without loops, and therefore we need to devise a scheme for * safe looping. */ /* * Suppose we want to measure how much it takes to execute work() with different * arguments. This mimics a frequent use case when multiple instances with the same * implementation, but different data, is measured. */ static final int BASE = 42; static int work(int x) { return BASE + x; } /* * Every benchmark requires control. We do a trivial control for our benchmarks * by checking the benchmark costs are growing linearly with increased task size. * If it doesn't, then something wrong is happening. */ @Param({"1", "10", "100", "1000"}) int size; int[] xs; @Setup public void setup() { xs = new int[size]; for (int c = 0; c < size; c++) { xs[c] = c; } } /* * First, the obviously wrong way: "saving" the result into a local variable would not * work. A sufficiently smart compiler will inline work(), and figure out only the last * work() call needs to be evaluated. Indeed, if you run it with varying $size, the score * will stay the same! */ @Benchmark public int measureWrong_1() { int acc = 0; for (int x : xs) { acc = work(x); } return acc; } /* * Second, another wrong way: "accumulating" the result into a local variable. While * it would force the computation of each work() method, there are software pipelining * effects in action, that can merge the operations between two otherwise distinct work() * bodies. This will obliterate the benchmark setup. * * In this example, HotSpot does the unrolled loop, merges the $BASE operands into a single * addition to $acc, and then does a bunch of very tight stores of $x-s. The final performance * depends on how much of the loop unrolling happened *and* how much data is available to make * the large strides. */ @Benchmark public int measureWrong_2() { int acc = 0; for (int x : xs) { acc += work(x); } return acc; } /* * Now, let's see how to measure these things properly. A very straight-forward way to * break the merging is to sink each result to Blackhole. This will force runtime to compute * every work() call in full. (We would normally like to care about several concurrent work() * computations at once, but the memory effects from Blackhole.consume() prevent those optimization * on most runtimes). */ @Benchmark public void measureRight_1(Blackhole bh) { for (int x : xs) { bh.consume(work(x)); } } /* * DANGEROUS AREA, PLEASE READ THE DESCRIPTION BELOW. * * Sometimes, the cost of sinking the value into a Blackhole is dominating the nano-benchmark score. * In these cases, one may try to do a make-shift "sinker" with non-inlineable method. This trick is * *very* VM-specific, and can only be used if you are verifying the generated code (that's a good * strategy when dealing with nano-benchmarks anyway). * * You SHOULD NOT use this trick in most cases. Apply only where needed. */ @Benchmark public void measureRight_2() { for (int x : xs) { sink(work(x)); } } @CompilerControl(CompilerControl.Mode.DONT_INLINE) public static void sink(int v) { // IT IS VERY IMPORTANT TO MATCH THE SIGNATURE TO AVOID AUTOBOXING. // The method intentionally does nothing. } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You might notice measureWrong_1 does not depend on $size, measureWrong_2 has troubles with * linearity, and otherwise much faster than both measureRight_*. You can also see measureRight_2 * is marginally faster than measureRight_1. * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_34 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_34_SafeLooping.class.getSimpleName()) .forks(3) .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java000066400000000000000000001157551446271450100305420ustar00rootroot00000000000000/* * Copyright (c) 2014, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.profile.ClassloaderProfiler; import org.openjdk.jmh.profile.DTraceAsmProfiler; import org.openjdk.jmh.profile.LinuxPerfProfiler; import org.openjdk.jmh.profile.StackProfiler; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; public class JMHSample_35_Profilers { /* * This sample serves as the profiler overview. * * JMH has a few very handy profilers that help to understand your benchmarks. While * these profilers are not the substitute for full-fledged external profilers, in many * cases, these are handy to quickly dig into the benchmark behavior. When you are * doing many cycles of tuning up the benchmark code itself, it is important to have * a quick turnaround for the results. * * Use -lprof to list the profilers. There are quite a few profilers, and this sample * would expand on a handful of most useful ones. Many profilers have their own options, * usually accessible via -prof :help. * * Since profilers are reporting on different things, it is hard to construct a single * benchmark sample that will show all profilers in action. Therefore, we have a couple * of benchmarks in this sample. */ /* * ================================ MAPS BENCHMARK ================================ */ @State(Scope.Thread) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(3) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public static class Maps { private Map map; @Param({"hashmap", "treemap"}) private String type; private int begin; private int end; @Setup public void setup() { switch (type) { case "hashmap": map = new HashMap<>(); break; case "treemap": map = new TreeMap<>(); break; default: throw new IllegalStateException("Unknown type: " + type); } begin = 1; end = 256; for (int i = begin; i < end; i++) { map.put(i, i); } } @Benchmark public void test(Blackhole bh) { for (int i = begin; i < end; i++) { bh.consume(map.get(i)); } } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_35.*Maps -prof stack * $ java -jar target/benchmarks.jar JMHSample_35.*Maps -prof gc * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_35_Profilers.Maps.class.getSimpleName()) .addProfiler(StackProfiler.class) // .addProfiler(GCProfiler.class) .build(); new Runner(opt).run(); } /* Running this benchmark will yield something like: Benchmark (type) Mode Cnt Score Error Units JMHSample_35_Profilers.Maps.test hashmap avgt 5 1553.201 ± 6.199 ns/op JMHSample_35_Profilers.Maps.test treemap avgt 5 5177.065 ± 361.278 ns/op Running with -prof stack will yield: ....[Thread state: RUNNABLE]........................................................................ 99.0% 99.0% org.openjdk.jmh.samples.JMHSample_35_Profilers$Maps.test 0.4% 0.4% org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Maps_test.test_avgt_jmhStub 0.2% 0.2% sun.reflect.NativeMethodAccessorImpl.invoke0 0.2% 0.2% java.lang.Integer.valueOf 0.2% 0.2% sun.misc.Unsafe.compareAndSwapInt ....[Thread state: RUNNABLE]........................................................................ 78.0% 78.0% java.util.TreeMap.getEntry 21.2% 21.2% org.openjdk.jmh.samples.JMHSample_35_Profilers$Maps.test 0.4% 0.4% java.lang.Integer.valueOf 0.2% 0.2% sun.reflect.NativeMethodAccessorImpl.invoke0 0.2% 0.2% org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Maps_test.test_avgt_jmhStub Stack profiler is useful to quickly see if the code we are stressing actually executes. As many other sampling profilers, it is susceptible for sampling bias: it can fail to notice quickly executing methods, for example. In the benchmark above, it does not notice HashMap.get. Next up, GC profiler. Running with -prof gc will yield: Benchmark (type) Mode Cnt Score Error Units JMHSample_35_Profilers.Maps.test hashmap avgt 5 1553.201 ± 6.199 ns/op JMHSample_35_Profilers.Maps.test:gc.alloc.rate hashmap avgt 5 1257.046 ± 5.675 MB/sec JMHSample_35_Profilers.Maps.test:gc.alloc.rate.norm hashmap avgt 5 2048.001 ± 0.001 B/op JMHSample_35_Profilers.Maps.test:gc.churn.PS_Eden_Space hashmap avgt 5 1259.148 ± 315.277 MB/sec JMHSample_35_Profilers.Maps.test:gc.churn.PS_Eden_Space.norm hashmap avgt 5 2051.519 ± 520.324 B/op JMHSample_35_Profilers.Maps.test:gc.churn.PS_Survivor_Space hashmap avgt 5 0.175 ± 0.386 MB/sec JMHSample_35_Profilers.Maps.test:gc.churn.PS_Survivor_Space.norm hashmap avgt 5 0.285 ± 0.629 B/op JMHSample_35_Profilers.Maps.test:gc.count hashmap avgt 5 29.000 counts JMHSample_35_Profilers.Maps.test:gc.time hashmap avgt 5 16.000 ms JMHSample_35_Profilers.Maps.test treemap avgt 5 5177.065 ± 361.278 ns/op JMHSample_35_Profilers.Maps.test:gc.alloc.rate treemap avgt 5 377.251 ± 26.188 MB/sec JMHSample_35_Profilers.Maps.test:gc.alloc.rate.norm treemap avgt 5 2048.003 ± 0.001 B/op JMHSample_35_Profilers.Maps.test:gc.churn.PS_Eden_Space treemap avgt 5 392.743 ± 174.156 MB/sec JMHSample_35_Profilers.Maps.test:gc.churn.PS_Eden_Space.norm treemap avgt 5 2131.767 ± 913.941 B/op JMHSample_35_Profilers.Maps.test:gc.churn.PS_Survivor_Space treemap avgt 5 0.131 ± 0.215 MB/sec JMHSample_35_Profilers.Maps.test:gc.churn.PS_Survivor_Space.norm treemap avgt 5 0.709 ± 1.125 B/op JMHSample_35_Profilers.Maps.test:gc.count treemap avgt 5 25.000 counts JMHSample_35_Profilers.Maps.test:gc.time treemap avgt 5 26.000 ms There, we can see that the tests are producing quite some garbage. "gc.alloc" would say we are allocating 1257 and 377 MB of objects per second, or 2048 bytes per benchmark operation. "gc.churn" would say that GC removes the same amount of garbage from Eden space every second. In other words, we are producing 2048 bytes of garbage per benchmark operation. If you look closely at the test, you can get a (correct) hypothesis this is due to Integer autoboxing. Note that "gc.alloc" counters generally produce more accurate data, but they can also fail when threads come and go over the course of the benchmark. "gc.churn" values are updated on each GC event, and so if you want a more accurate data, running longer and/or with small heap would help. But anyhow, always cross-reference "gc.alloc" and "gc.churn" values with each other to get a complete picture. It is also worth noticing that non-normalized counters are dependent on benchmark performance! Here, "treemap" tests are 3x slower, and thus both allocation and churn rates are also comparably lower. It is often useful to look into non-normalized counters to see if the test is allocation/GC-bound (figure the allocation pressure "ceiling" for your configuration!), and normalized counters to see the more precise benchmark behavior. As most profilers, both "stack" and "gc" profile are able to aggregate samples from multiple forks. It is a good idea to run multiple forks with the profilers enabled, as it improves results error estimates. */ } /* * ================================ CLASSLOADER BENCHMARK ================================ */ @State(Scope.Thread) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(3) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public static class Classy { /** * Our own crippled classloader, that can only load a simple class over and over again. */ public static class XLoader extends URLClassLoader { private static final byte[] X_BYTECODE = new byte[]{ (byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE, 0x00, 0x00, 0x00, 0x34, 0x00, 0x0D, 0x0A, 0x00, 0x03, 0x00, 0x0A, 0x07, 0x00, 0x0B, 0x07, 0x00, 0x0C, 0x01, 0x00, 0x06, 0x3C, 0x69, 0x6E, 0x69, 0x74, 0x3E, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x04, 0x43, 0x6F, 0x64, 0x65, 0x01, 0x00, 0x0F, 0x4C, 0x69, 0x6E, 0x65, 0x4E, 0x75, 0x6D, 0x62, 0x65, 0x72, 0x54, 0x61, 0x62, 0x6C, 0x65, 0x01, 0x00, 0x0A, 0x53, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6C, 0x65, 0x01, 0x00, 0x06, 0x58, 0x2E, 0x6A, 0x61, 0x76, 0x61, 0x0C, 0x00, 0x04, 0x00, 0x05, 0x01, 0x00, 0x01, 0x58, 0x01, 0x00, 0x10, 0x6A, 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 0x2F, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x20, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x05, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2A, (byte) 0xB7, 0x00, 0x01, (byte) 0xB1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x09, }; public XLoader() { super(new URL[0], ClassLoader.getSystemClassLoader()); } @Override protected Class findClass(final String name) throws ClassNotFoundException { return defineClass(name, X_BYTECODE, 0, X_BYTECODE.length); } } @Benchmark public Class load() throws ClassNotFoundException { return Class.forName("X", true, new XLoader()); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_35.*Classy -prof cl * $ java -jar target/benchmarks.jar JMHSample_35.*Classy -prof comp * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_35_Profilers.Classy.class.getSimpleName()) .addProfiler(ClassloaderProfiler.class) // .addProfiler(CompilerProfiler.class) .build(); new Runner(opt).run(); } /* Running with -prof cl will yield: Benchmark Mode Cnt Score Error Units JMHSample_35_Profilers.Classy.load avgt 15 34215.363 ± 545.892 ns/op JMHSample_35_Profilers.Classy.load:class.load avgt 15 29374.097 ± 716.743 classes/sec JMHSample_35_Profilers.Classy.load:class.load.norm avgt 15 1.000 ± 0.001 classes/op JMHSample_35_Profilers.Classy.load:class.unload avgt 15 29598.233 ± 3420.181 classes/sec JMHSample_35_Profilers.Classy.load:class.unload.norm avgt 15 1.008 ± 0.119 classes/op Here, we can see the benchmark indeed load class per benchmark op, and this adds up to more than 29K classloads per second. We can also see the runtime is able to successfully keep the number of loaded classes at bay, since the class unloading happens at the same rate. This profiler is handy when doing the classloading performance work, because it says if the classes were actually loaded, and not reused across the Class.forName calls. It also helps to see if the benchmark performs any classloading in the measurement phase. For example, if you have non-classloading benchmark, you would expect these metrics be zero. Another useful profiler that could tell if compiler is doing a heavy work in background, and thus interfering with measurement, -prof comp: Benchmark Mode Cnt Score Error Units JMHSample_35_Profilers.Classy.load avgt 5 33523.875 ± 3026.025 ns/op JMHSample_35_Profilers.Classy.load:compiler.time.profiled avgt 5 5.000 ms JMHSample_35_Profilers.Classy.load:compiler.time.total avgt 5 479.000 ms We seem to be at proper steady state: out of 479 ms of total compiler work, only 5 ms happen during the measurement window. It is expected to have some level of background compilation even at steady state. As most profilers, both "cl" and "comp" are able to aggregate samples from multiple forks. It is a good idea to run multiple forks with the profilers enabled, as it improves results error estimates. */ } /* * ================================ ATOMIC LONG BENCHMARK ================================ */ @State(Scope.Benchmark) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public static class Atomic { private AtomicLong n; @Setup public void setup() { n = new AtomicLong(); } @Benchmark public long test() { return n.incrementAndGet(); } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof perf -f 1 (Linux) * $ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof perfnorm -f 3 (Linux) * $ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof perfasm -f 1 (Linux) * $ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof xperfasm -f 1 (Windows) * $ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof dtraceasm -f 1 (Mac OS X) * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_35_Profilers.Atomic.class.getSimpleName()) .addProfiler(LinuxPerfProfiler.class) // .addProfiler(LinuxPerfNormProfiler.class) // .addProfiler(LinuxPerfAsmProfiler.class) // .addProfiler(WinPerfAsmProfiler.class) // .addProfiler(DTraceAsmProfiler.class) .build(); new Runner(opt).run(); } /* Dealing with nanobenchmarks like these requires looking into the abyss of runtime, hardware, and generated code. Luckily, JMH has a few handy tools that ease the pain. If you are running Linux, then perf_events are probably available as standard package. This kernel facility taps into hardware counters, and provides the data for user space programs like JMH. Windows has less sophisticated facilities, but also usable, see below. One can simply run "perf stat java -jar ..." to get the first idea how the workload behaves. In JMH case, however, this will cause perf to profile both host and forked JVMs. -prof perf avoids that: JMH invokes perf for the forked VM alone. For the benchmark above, it would print something like: Perf stats: -------------------------------------------------- 4172.776137 task-clock (msec) # 0.411 CPUs utilized 612 context-switches # 0.147 K/sec 31 cpu-migrations # 0.007 K/sec 195 page-faults # 0.047 K/sec 16,599,643,026 cycles # 3.978 GHz [30.80%] stalled-cycles-frontend stalled-cycles-backend 17,815,084,879 instructions # 1.07 insns per cycle [38.49%] 3,813,373,583 branches # 913.870 M/sec [38.56%] 1,212,788 branch-misses # 0.03% of all branches [38.91%] 7,582,256,427 L1-dcache-loads # 1817.077 M/sec [39.07%] 312,913 L1-dcache-load-misses # 0.00% of all L1-dcache hits [38.66%] 35,688 LLC-loads # 0.009 M/sec [32.58%] LLC-load-misses:HG L1-icache-loads:HG 161,436 L1-icache-load-misses:HG # 0.00% of all L1-icache hits [32.81%] 7,200,981,198 dTLB-loads:HG # 1725.705 M/sec [32.68%] 3,360 dTLB-load-misses:HG # 0.00% of all dTLB cache hits [32.65%] 193,874 iTLB-loads:HG # 0.046 M/sec [32.56%] 4,193 iTLB-load-misses:HG # 2.16% of all iTLB cache hits [32.44%] L1-dcache-prefetches:HG 0 L1-dcache-prefetch-misses:HG # 0.000 K/sec [32.33%] 10.159432892 seconds time elapsed We can already see this benchmark goes with good IPC, does lots of loads and lots of stores, all of them are more or less fulfilled without misses. The data like this is not handy though: you would like to normalize the counters per benchmark op. This is exactly what -prof perfnorm does: Benchmark Mode Cnt Score Error Units JMHSample_35_Profilers.Atomic.test avgt 15 6.551 ± 0.023 ns/op JMHSample_35_Profilers.Atomic.test:CPI avgt 3 0.933 ± 0.026 #/op JMHSample_35_Profilers.Atomic.test:L1-dcache-load-misses avgt 3 0.001 ± 0.022 #/op JMHSample_35_Profilers.Atomic.test:L1-dcache-loads avgt 3 12.267 ± 1.324 #/op JMHSample_35_Profilers.Atomic.test:L1-dcache-store-misses avgt 3 0.001 ± 0.006 #/op JMHSample_35_Profilers.Atomic.test:L1-dcache-stores avgt 3 4.090 ± 0.402 #/op JMHSample_35_Profilers.Atomic.test:L1-icache-load-misses avgt 3 0.001 ± 0.011 #/op JMHSample_35_Profilers.Atomic.test:LLC-loads avgt 3 0.001 ± 0.004 #/op JMHSample_35_Profilers.Atomic.test:LLC-stores avgt 3 ≈ 10⁻⁴ #/op JMHSample_35_Profilers.Atomic.test:branch-misses avgt 3 ≈ 10⁻⁴ #/op JMHSample_35_Profilers.Atomic.test:branches avgt 3 6.152 ± 0.385 #/op JMHSample_35_Profilers.Atomic.test:bus-cycles avgt 3 0.670 ± 0.048 #/op JMHSample_35_Profilers.Atomic.test:context-switches avgt 3 ≈ 10⁻⁶ #/op JMHSample_35_Profilers.Atomic.test:cpu-migrations avgt 3 ≈ 10⁻⁷ #/op JMHSample_35_Profilers.Atomic.test:cycles avgt 3 26.790 ± 1.393 #/op JMHSample_35_Profilers.Atomic.test:dTLB-load-misses avgt 3 ≈ 10⁻⁴ #/op JMHSample_35_Profilers.Atomic.test:dTLB-loads avgt 3 12.278 ± 0.277 #/op JMHSample_35_Profilers.Atomic.test:dTLB-store-misses avgt 3 ≈ 10⁻⁵ #/op JMHSample_35_Profilers.Atomic.test:dTLB-stores avgt 3 4.113 ± 0.437 #/op JMHSample_35_Profilers.Atomic.test:iTLB-load-misses avgt 3 ≈ 10⁻⁵ #/op JMHSample_35_Profilers.Atomic.test:iTLB-loads avgt 3 0.001 ± 0.034 #/op JMHSample_35_Profilers.Atomic.test:instructions avgt 3 28.729 ± 1.297 #/op JMHSample_35_Profilers.Atomic.test:minor-faults avgt 3 ≈ 10⁻⁷ #/op JMHSample_35_Profilers.Atomic.test:page-faults avgt 3 ≈ 10⁻⁷ #/op JMHSample_35_Profilers.Atomic.test:ref-cycles avgt 3 26.734 ± 2.081 #/op It is customary to trim the lines irrelevant to the particular benchmark. We show all of them here for completeness. We can see that the benchmark does ~12 loads per benchmark op, and about ~4 stores per op, most of them fitting in the cache. There are also ~6 branches per benchmark op, all are predicted as well. It is also easy to see the benchmark op takes ~28 instructions executed in ~27 cycles. The output would get more interesting when we run with more threads, say, -t 8: Benchmark Mode Cnt Score Error Units JMHSample_35_Profilers.Atomic.test avgt 15 143.595 ± 1.968 ns/op JMHSample_35_Profilers.Atomic.test:CPI avgt 3 17.741 ± 28.761 #/op JMHSample_35_Profilers.Atomic.test:L1-dcache-load-misses avgt 3 0.175 ± 0.406 #/op JMHSample_35_Profilers.Atomic.test:L1-dcache-loads avgt 3 11.872 ± 0.786 #/op JMHSample_35_Profilers.Atomic.test:L1-dcache-store-misses avgt 3 0.184 ± 0.505 #/op JMHSample_35_Profilers.Atomic.test:L1-dcache-stores avgt 3 4.422 ± 0.561 #/op JMHSample_35_Profilers.Atomic.test:L1-icache-load-misses avgt 3 0.015 ± 0.083 #/op JMHSample_35_Profilers.Atomic.test:LLC-loads avgt 3 0.015 ± 0.128 #/op JMHSample_35_Profilers.Atomic.test:LLC-stores avgt 3 1.036 ± 0.045 #/op JMHSample_35_Profilers.Atomic.test:branch-misses avgt 3 0.224 ± 0.492 #/op JMHSample_35_Profilers.Atomic.test:branches avgt 3 6.524 ± 2.873 #/op JMHSample_35_Profilers.Atomic.test:bus-cycles avgt 3 13.475 ± 14.502 #/op JMHSample_35_Profilers.Atomic.test:context-switches avgt 3 ≈ 10⁻⁴ #/op JMHSample_35_Profilers.Atomic.test:cpu-migrations avgt 3 ≈ 10⁻⁶ #/op JMHSample_35_Profilers.Atomic.test:cycles avgt 3 537.874 ± 595.723 #/op JMHSample_35_Profilers.Atomic.test:dTLB-load-misses avgt 3 0.001 ± 0.006 #/op JMHSample_35_Profilers.Atomic.test:dTLB-loads avgt 3 12.032 ± 2.430 #/op JMHSample_35_Profilers.Atomic.test:dTLB-store-misses avgt 3 ≈ 10⁻⁴ #/op JMHSample_35_Profilers.Atomic.test:dTLB-stores avgt 3 4.557 ± 0.948 #/op JMHSample_35_Profilers.Atomic.test:iTLB-load-misses avgt 3 ≈ 10⁻³ #/op JMHSample_35_Profilers.Atomic.test:iTLB-loads avgt 3 0.016 ± 0.052 #/op JMHSample_35_Profilers.Atomic.test:instructions avgt 3 30.367 ± 15.052 #/op JMHSample_35_Profilers.Atomic.test:minor-faults avgt 3 ≈ 10⁻⁵ #/op JMHSample_35_Profilers.Atomic.test:page-faults avgt 3 ≈ 10⁻⁵ #/op JMHSample_35_Profilers.Atomic.test:ref-cycles avgt 3 538.697 ± 590.183 #/op Note how this time the CPI is awfully high: 17 cycles per instruction! Indeed, we are making almost the same ~30 instructions, but now they take >530 cycles. Other counters highlight why: we now have cache misses on both loads and stores, on all levels of cache hierarchy. With a simple constant-footprint like ours, that's an indication of sharing problems. Indeed, our AtomicLong is heavily-contended with 8 threads. "perfnorm", again, can (and should!) be used with multiple forks, to properly estimate the metrics. The last, but not the least player on our field is -prof perfasm. It is important to follow up on generated code when dealing with fine-grained benchmarks. We could employ PrintAssembly to dump the generated code, but it will dump *all* the generated code, and figuring out what is related to our benchmark is a daunting task. But we have "perf" that can tell what program addresses are really hot! This enables us to contrast the assembly output. -prof perfasm would indeed contrast out the hottest loop in the generated code! It will also point fingers at "lock xadd" as the hottest instruction in our code. Hardware counters are not very precise about the instruction addresses, so sometimes they attribute the events to the adjacent code lines. Hottest code regions (>10.00% "cycles" events): ....[Hottest Region 1].............................................................................. [0x7f1824f87c45:0x7f1824f87c79] in org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@29 (line 201) ; implicit exception: dispatches to 0x00007f1824f87d21 0x00007f1824f87c25: test %r11d,%r11d 0x00007f1824f87c28: jne 0x00007f1824f87cbd ;*ifeq ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@32 (line 201) 0x00007f1824f87c2e: mov $0x1,%ebp 0x00007f1824f87c33: nopw 0x0(%rax,%rax,1) 0x00007f1824f87c3c: xchg %ax,%ax ;*aload ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@13 (line 199) 0x00007f1824f87c40: mov 0x8(%rsp),%r10 0.00% 0x00007f1824f87c45: mov 0xc(%r10),%r11d ;*getfield n ; - org.openjdk.jmh.samples.JMHSample_35_Profilers$Atomic::test@1 (line 280) ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@16 (line 199) 0.19% 0.02% 0x00007f1824f87c49: test %r11d,%r11d 0x00007f1824f87c4c: je 0x00007f1824f87cad 0x00007f1824f87c4e: mov $0x1,%edx 0x00007f1824f87c53: lock xadd %rdx,0x10(%r12,%r11,8) ;*invokevirtual getAndAddLong ; - java.util.concurrent.atomic.AtomicLong::incrementAndGet@8 (line 200) ; - org.openjdk.jmh.samples.JMHSample_35_Profilers$Atomic::test@4 (line 280) ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@16 (line 199) 95.20% 95.06% 0x00007f1824f87c5a: add $0x1,%rdx ;*ladd ; - java.util.concurrent.atomic.AtomicLong::incrementAndGet@12 (line 200) ; - org.openjdk.jmh.samples.JMHSample_35_Profilers$Atomic::test@4 (line 280) ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@16 (line 199) 0.24% 0.00% 0x00007f1824f87c5e: mov 0x10(%rsp),%rsi 0x00007f1824f87c63: callq 0x00007f1824e2b020 ; OopMap{[0]=Oop [8]=Oop [16]=Oop [24]=Oop off=232} ;*invokevirtual consume ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@19 (line 199) ; {optimized virtual_call} 0.20% 0.01% 0x00007f1824f87c68: mov 0x18(%rsp),%r10 0x00007f1824f87c6d: movzbl 0x94(%r10),%r11d ;*getfield isDone ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@29 (line 201) 0.00% 0x00007f1824f87c75: add $0x1,%rbp ; OopMap{r10=Oop [0]=Oop [8]=Oop [16]=Oop [24]=Oop off=249} ;*ifeq ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@32 (line 201) 0.20% 0.01% 0x00007f1824f87c79: test %eax,0x15f36381(%rip) # 0x00007f183aebe000 ; {poll} 0x00007f1824f87c7f: test %r11d,%r11d 0x00007f1824f87c82: je 0x00007f1824f87c40 ;*aload_2 ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@35 (line 202) 0x00007f1824f87c84: mov $0x7f1839be4220,%r10 0x00007f1824f87c8e: callq *%r10 ;*invokestatic nanoTime ; - org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub@36 (line 202) 0x00007f1824f87c91: mov (%rsp),%r10 .................................................................................................... 96.03% 95.10% perfasm would also print the hottest methods to show if we indeed spending time in our benchmark. Most of the time, it can demangle VM and kernel symbols as well: ....[Hottest Methods (after inlining)].............................................................. 96.03% 95.10% org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_avgt_jmhStub 0.73% 0.78% org.openjdk.jmh.samples.generated.JMHSample_35_Profilers_Atomic_test::test_AverageTime 0.63% 0.00% org.openjdk.jmh.infra.Blackhole::consume 0.23% 0.25% native_write_msr_safe ([kernel.kallsyms]) 0.09% 0.05% _raw_spin_unlock ([kernel.kallsyms]) 0.09% 0.00% [unknown] (libpthread-2.19.so) 0.06% 0.07% _raw_spin_lock ([kernel.kallsyms]) 0.06% 0.04% _raw_spin_unlock_irqrestore ([kernel.kallsyms]) 0.06% 0.05% _IO_fwrite (libc-2.19.so) 0.05% 0.03% __srcu_read_lock; __srcu_read_unlock ([kernel.kallsyms]) 0.04% 0.05% _raw_spin_lock_irqsave ([kernel.kallsyms]) 0.04% 0.06% vfprintf (libc-2.19.so) 0.04% 0.01% mutex_unlock ([kernel.kallsyms]) 0.04% 0.01% _nv014306rm ([nvidia]) 0.04% 0.04% rcu_eqs_enter_common.isra.47 ([kernel.kallsyms]) 0.04% 0.02% mutex_lock ([kernel.kallsyms]) 0.03% 0.07% __acct_update_integrals ([kernel.kallsyms]) 0.03% 0.02% fget_light ([kernel.kallsyms]) 0.03% 0.01% fput ([kernel.kallsyms]) 0.03% 0.04% rcu_eqs_exit_common.isra.48 ([kernel.kallsyms]) 1.63% 2.26% <...other 319 warm methods...> .................................................................................................... 100.00% 98.97% ....[Distribution by Area].......................................................................... 97.44% 95.99% 1.60% 2.42% 0.47% 0.78% 0.22% 0.29% 0.15% 0.07% 0.07% 0.38% 0.05% 0.06% 0.00% 0.00% 0.00% 0.00% .................................................................................................... 100.00% 100.00% Since program addresses change from fork to fork, it does not make sense to run perfasm with more than a single fork. */ } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_36_BranchPrediction.java000066400000000000000000000143721446271450100320050ustar00rootroot00000000000000/* * Copyright (c) 2015, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Arrays; import java.util.Random; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(5) @State(Scope.Benchmark) public class JMHSample_36_BranchPrediction { /* * This sample serves as a warning against regular data sets. * * It is very tempting to present a regular data set to benchmark, either due to * naive generation strategy, or just from feeling better about regular data sets. * Unfortunately, it frequently backfires: the regular datasets are known to be * optimized well by software and hardware. This example exploits one of these * optimizations: branch prediction. * * Imagine our benchmark selects the branch based on the array contents, as * we are streaming through it: */ private static final int COUNT = 1024 * 1024; private byte[] sorted; private byte[] unsorted; @Setup public void setup() { sorted = new byte[COUNT]; unsorted = new byte[COUNT]; Random random = new Random(1234); random.nextBytes(sorted); random.nextBytes(unsorted); Arrays.sort(sorted); } @Benchmark @OperationsPerInvocation(COUNT) public void sorted(Blackhole bh1, Blackhole bh2) { for (byte v : sorted) { if (v > 0) { bh1.consume(v); } else { bh2.consume(v); } } } @Benchmark @OperationsPerInvocation(COUNT) public void unsorted(Blackhole bh1, Blackhole bh2) { for (byte v : unsorted) { if (v > 0) { bh1.consume(v); } else { bh2.consume(v); } } } /* There is a substantial difference in performance for these benchmarks! It is explained by good branch prediction in "sorted" case, and branch mispredicts in "unsorted" case. -prof perfnorm conveniently highlights that, with larger "branch-misses", and larger "CPI" for "unsorted" case: Benchmark Mode Cnt Score Error Units JMHSample_36_BranchPrediction.sorted avgt 25 2.160 ± 0.049 ns/op JMHSample_36_BranchPrediction.sorted:CPI avgt 5 0.286 ± 0.025 #/op JMHSample_36_BranchPrediction.sorted:branch-misses avgt 5 ≈ 10⁻⁴ #/op JMHSample_36_BranchPrediction.sorted:branches avgt 5 7.606 ± 1.742 #/op JMHSample_36_BranchPrediction.sorted:cycles avgt 5 8.998 ± 1.081 #/op JMHSample_36_BranchPrediction.sorted:instructions avgt 5 31.442 ± 4.899 #/op JMHSample_36_BranchPrediction.unsorted avgt 25 5.943 ± 0.018 ns/op JMHSample_36_BranchPrediction.unsorted:CPI avgt 5 0.775 ± 0.052 #/op JMHSample_36_BranchPrediction.unsorted:branch-misses avgt 5 0.529 ± 0.026 #/op <--- OOPS JMHSample_36_BranchPrediction.unsorted:branches avgt 5 7.841 ± 0.046 #/op JMHSample_36_BranchPrediction.unsorted:cycles avgt 5 24.793 ± 0.434 #/op JMHSample_36_BranchPrediction.unsorted:instructions avgt 5 31.994 ± 2.342 #/op It is an open question if you want to measure only one of these tests. In many cases, you have to measure both to get the proper best-case and worst-case estimate! */ /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_36 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(".*" + JMHSample_36_BranchPrediction.class.getSimpleName() + ".*") .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_37_CacheAccess.java000066400000000000000000000141271446271450100307130ustar00rootroot00000000000000/* * Copyright (c) 2015, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Random; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(5) @State(Scope.Benchmark) public class JMHSample_37_CacheAccess { /* * This sample serves as a warning against subtle differences in cache access patterns. * * Many performance differences may be explained by the way tests are accessing memory. * In the example below, we walk the matrix either row-first, or col-first: */ private final static int COUNT = 4096; private final static int MATRIX_SIZE = COUNT * COUNT; private int[][] matrix; @Setup public void setup() { matrix = new int[COUNT][COUNT]; Random random = new Random(1234); for (int i = 0; i < COUNT; i++) { for (int j = 0; j < COUNT; j++) { matrix[i][j] = random.nextInt(); } } } @Benchmark @OperationsPerInvocation(MATRIX_SIZE) public void colFirst(Blackhole bh) { for (int c = 0; c < COUNT; c++) { for (int r = 0; r < COUNT; r++) { bh.consume(matrix[r][c]); } } } @Benchmark @OperationsPerInvocation(MATRIX_SIZE) public void rowFirst(Blackhole bh) { for (int r = 0; r < COUNT; r++) { for (int c = 0; c < COUNT; c++) { bh.consume(matrix[r][c]); } } } /* Notably, colFirst accesses are much slower, and that's not a surprise: Java's multidimensional arrays are actually rigged, being one-dimensional arrays of one-dimensional arrays. Therefore, pulling n-th element from each of the inner array induces more cache misses, when matrix is large. -prof perfnorm conveniently highlights that, with >2 cache misses per one benchmark op: Benchmark Mode Cnt Score Error Units JMHSample_37_MatrixCopy.colFirst avgt 25 5.306 ± 0.020 ns/op JMHSample_37_MatrixCopy.colFirst:CPI avgt 5 0.621 ± 0.011 #/op JMHSample_37_MatrixCopy.colFirst:L1-dcache-load-misses avgt 5 2.177 ± 0.044 #/op <-- OOPS JMHSample_37_MatrixCopy.colFirst:L1-dcache-loads avgt 5 14.804 ± 0.261 #/op JMHSample_37_MatrixCopy.colFirst:LLC-loads avgt 5 2.165 ± 0.091 #/op JMHSample_37_MatrixCopy.colFirst:cycles avgt 5 22.272 ± 0.372 #/op JMHSample_37_MatrixCopy.colFirst:instructions avgt 5 35.888 ± 1.215 #/op JMHSample_37_MatrixCopy.rowFirst avgt 25 2.662 ± 0.003 ns/op JMHSample_37_MatrixCopy.rowFirst:CPI avgt 5 0.312 ± 0.003 #/op JMHSample_37_MatrixCopy.rowFirst:L1-dcache-load-misses avgt 5 0.066 ± 0.001 #/op JMHSample_37_MatrixCopy.rowFirst:L1-dcache-loads avgt 5 14.570 ± 0.400 #/op JMHSample_37_MatrixCopy.rowFirst:LLC-loads avgt 5 0.002 ± 0.001 #/op JMHSample_37_MatrixCopy.rowFirst:cycles avgt 5 11.046 ± 0.343 #/op JMHSample_37_MatrixCopy.rowFirst:instructions avgt 5 35.416 ± 1.248 #/op So, when comparing two different benchmarks, you have to follow up if the difference is caused by the memory locality issues. */ /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_37 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(".*" + JMHSample_37_CacheAccess.class.getSimpleName() + ".*") .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_38_PerInvokeSetup.java000066400000000000000000000152511446271450100315110ustar00rootroot00000000000000/* * Copyright (c) 2015, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.Arrays; import java.util.Random; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(5) public class JMHSample_38_PerInvokeSetup { /* * This example highlights the usual mistake in non-steady-state benchmarks. * * Suppose we want to test how long it takes to bubble sort an array. Naively, * we could make the test that populates an array with random (unsorted) values, * and calls sort on it over and over again: */ private void bubbleSort(byte[] b) { boolean changed = true; while (changed) { changed = false; for (int c = 0; c < b.length - 1; c++) { if (b[c] > b[c + 1]) { byte t = b[c]; b[c] = b[c + 1]; b[c + 1] = t; changed = true; } } } } // Could be an implicit State instead, but we are going to use it // as the dependency in one of the tests below @State(Scope.Benchmark) public static class Data { @Param({"1", "16", "256"}) int count; byte[] arr; @Setup public void setup() { arr = new byte[count]; Random random = new Random(1234); random.nextBytes(arr); } } @Benchmark public byte[] measureWrong(Data d) { bubbleSort(d.arr); return d.arr; } /* * The method above is subtly wrong: it sorts the random array on the first invocation * only. Every subsequent call will "sort" the already sorted array. With bubble sort, * that operation would be significantly faster! * * This is how we might *try* to measure it right by making a copy in Level.Invocation * setup. However, this is susceptible to the problems described in Level.Invocation * Javadocs, READ AND UNDERSTAND THOSE DOCS BEFORE USING THIS APPROACH. */ @State(Scope.Thread) public static class DataCopy { byte[] copy; @Setup(Level.Invocation) public void setup2(Data d) { copy = Arrays.copyOf(d.arr, d.arr.length); } } @Benchmark public byte[] measureNeutral(DataCopy d) { bubbleSort(d.copy); return d.copy; } /* * In an overwhelming majority of cases, the only sensible thing to do is to suck up * the per-invocation setup costs into a benchmark itself. This work well in practice, * especially when the payload costs dominate the setup costs. */ @Benchmark public byte[] measureRight(Data d) { byte[] c = Arrays.copyOf(d.arr, d.arr.length); bubbleSort(c); return c; } /* Benchmark (count) Mode Cnt Score Error Units JMHSample_38_PerInvokeSetup.measureWrong 1 avgt 25 2.408 ± 0.011 ns/op JMHSample_38_PerInvokeSetup.measureWrong 16 avgt 25 8.286 ± 0.023 ns/op JMHSample_38_PerInvokeSetup.measureWrong 256 avgt 25 73.405 ± 0.018 ns/op JMHSample_38_PerInvokeSetup.measureNeutral 1 avgt 25 15.835 ± 0.470 ns/op JMHSample_38_PerInvokeSetup.measureNeutral 16 avgt 25 112.552 ± 0.787 ns/op JMHSample_38_PerInvokeSetup.measureNeutral 256 avgt 25 58343.848 ± 991.202 ns/op JMHSample_38_PerInvokeSetup.measureRight 1 avgt 25 6.075 ± 0.018 ns/op JMHSample_38_PerInvokeSetup.measureRight 16 avgt 25 102.390 ± 0.676 ns/op JMHSample_38_PerInvokeSetup.measureRight 256 avgt 25 58812.411 ± 997.951 ns/op We can clearly see that "measureWrong" provides a very weird result: it "sorts" way too fast. "measureNeutral" is neither good or bad: while it prepares the data for each invocation correctly, the timing overheads are clearly visible. These overheads can be overwhelming, depending on the thread count and/or OS flavor. */ /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_38 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(".*" + JMHSample_38_PerInvokeSetup.class.getSimpleName() + ".*") .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_39_MemoryAccess.java000066400000000000000000000120621446271450100311560ustar00rootroot00000000000000/* * Copyright (c) 2015, Oracle America, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Oracle nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Random; import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(5) @State(Scope.Benchmark) public class JMHSample_39_MemoryAccess { public static final int N = 20_000_000; /* * This example highlights the pitfall of accidentally measuring memory access instead of processing time. * * An int array has got a different memory layout than an ArrayList of boxed ints. * This can lead to useless results because the memory access is completely different. * Arrays save all their ints in one block on the heap while ArrayLists don't. * They save only references to the boxed ints in one block. * All the references point to the boxed ints which are usually spread all over the heap. * This leads to many cache misses with a big error: * * Benchmark Mode Cnt Score Error Units * JMHSample_39_MemoryAccess.sumArray avgt 25 4.887 ± 0.008 ms/op * JMHSample_39_MemoryAccess.sumArrayList avgt 25 35.765 ± 0.112 ms/op * JMHSample_39_MemoryAccess.sumArrayListShuffled avgt 25 169.301 ± 1.064 ms/op * * The Java Object Layout (JOL) is a tool with which the different memory layouts of arrays and ArrayLists can be * examined in more detail. */ private int[] intArray = new int[N]; private List intList = new ArrayList<>(N); private List shuffledIntList = new ArrayList<>(N); @Setup public void setup() { Random random = new Random(1234); for (int i = 0; i < N; i++) { intArray[i] = random.nextInt(); intList.add(intArray[i]); shuffledIntList.add(intArray[i]); } Collections.shuffle(shuffledIntList); } @Benchmark public long sumArray() { long sum = 0; for (int i = 0; i < N; i++) { sum += intArray[i]; } return sum; } @Benchmark public long sumArrayList() { long sum = 0; for (int i = 0; i < N; i++) { sum += intList.get(i); } return sum; } @Benchmark public long sumArrayListShuffled() { long sum = 0; for (int i = 0; i < N; i++) { sum += shuffledIntList.get(i); } return sum; } /* * ============================== HOW TO RUN THIS TEST: ==================================== * * You can run this test: * * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_39 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) */ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(".*" + JMHSample_39_MemoryAccess.class.getSimpleName() + ".*") .build(); new Runner(opt).run(); } } jmh-1.37/jmh-samples/src/main/resources/000077500000000000000000000000001446271450100201735ustar00rootroot00000000000000jmh-1.37/jmh-samples/src/main/resources/LICENSE000066400000000000000000000027251446271450100212060ustar00rootroot00000000000000Copyright (c) 2014, Oracle America, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Oracle nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. jmh-1.37/jmh-samples/src/main/resources/THIRD-PARTY000066400000000000000000000350611446271450100216720ustar00rootroot00000000000000DO NOT TRANSLATE OR LOCALIZE. ----------------------------- %% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- The MIT License Copyright (c) 2004-2021 Paul R. Holser, Jr. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- %% This notice is provided with respect to ASM v5.0.3 --- begin of LICENSE --- Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- end of LICENSE --- The following applies to all products licensed under the Apache 2.0 License: You may not use the identified files except in compliance with the Apache License, Version 2.0 (the "License.") You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jmh-1.37/pom.xml000066400000000000000000000266701446271450100135560ustar00rootroot00000000000000 4.0.0 org.openjdk.jmh jmh-parent pom 1.37 Java Microbenchmark Harness Parent JMH is the framework for writing and running Java nano/micro/millibenchmarks. http://openjdk.java.net/projects/code-tools/jmh/ https://github.com/openjdk/jmh scm:git:https://github.com/openjdk/jmh.git GNU General Public License (GPL), version 2, with the Classpath exception http://openjdk.java.net/legal/gplv2+ce.html shade Aleksey Shipilev Oracle/Sun, Red Hat current-development skuksenko Sergey Kuksenko Oracle/Sun current-development aastrand Anders Astrand Oracle/BEA initial-development sfriberg Staffan Friberg Oracle/BEA initial-development hloef Henrik Loef Oracle/BEA initial-development org.apache.maven.plugins maven-source-plugin attach-sources verify jar org.apache.maven.plugins maven-javadoc-plugin true 8 attach-javadoc verify jar org.apache.maven.plugins maven-eclipse-plugin true true org.apache.maven.plugins maven-enforcer-plugin enforce-maven enforce 3.2 org.apache.maven.plugins maven-compiler-plugin 3.8.0 1.8 1.8 1.8 org.apache.maven.plugins maven-surefire-plugin 2.16 false org.apache.maven.plugins maven-shade-plugin 3.2.1 org.apache.maven.plugins maven-enforcer-plugin 1.4.1 org.apache.maven.plugins maven-eclipse-plugin 2.10 org.apache.maven.plugins maven-javadoc-plugin 3.0.1 org.apache.maven.plugins maven-source-plugin 3.0.1 org.apache.maven.plugins maven-resources-plugin 2.6 com.mycila.maven-license-plugin maven-license-plugin 1.10.b1 org.codehaus.mojo build-helper-maven-plugin 1.8 org.codehaus.mojo exec-maven-plugin 1.3.1 org.apache.maven.plugins maven-site-plugin 3.3 org.codehaus.mojo cobertura-maven-plugin 2.6 org.apache.maven.plugins maven-jxr-plugin 2.4 org.codehaus.mojo findbugs-maven-plugin 2.5.3 org.apache.maven.plugins maven-checkstyle-plugin 2.12.1 org.codehaus.mojo taglist-maven-plugin 2.4 junit junit 4.13.2 test net.sf.jopt-simple jopt-simple 5.0.4 org.apache.commons commons-math3 3.6.1 org.ow2.asm asm 9.0 jmh-core jmh-core-it jmh-core-ct jmh-core-benchmarks jmh-samples jmh-generator-annprocess jmh-generator-asm jmh-generator-bytecode jmh-generator-reflection jmh-archetypes jmh-1.37/src/000077500000000000000000000000001446271450100130155ustar00rootroot00000000000000jmh-1.37/src/license/000077500000000000000000000000001446271450100144375ustar00rootroot00000000000000jmh-1.37/src/license/LICENSE000066400000000000000000000455121446271450100154530ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. jmh-1.37/src/license/bsd/000077500000000000000000000000001446271450100152075ustar00rootroot00000000000000jmh-1.37/src/license/bsd/header.txt000066400000000000000000000027241446271450100172050ustar00rootroot00000000000000Copyright (c) 2015, Oracle America, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Oracle nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. jmh-1.37/src/license/bsd/license.txt000066400000000000000000000027241446271450100173770ustar00rootroot00000000000000Copyright (c) 2014, Oracle America, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Oracle nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. jmh-1.37/src/license/gpl_cpe/000077500000000000000000000000001446271450100160505ustar00rootroot00000000000000jmh-1.37/src/license/gpl_cpe/header.txt000066400000000000000000000021701446271450100200410ustar00rootroot00000000000000Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. This code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 only, as published by the Free Software Foundation. Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code. This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for more details (a copy is included in the LICENSE file that accompanied this code). You should have received a copy of the GNU General Public License version 2 along with this work; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA or visit www.oracle.com if you need additional information or have any questions. jmh-1.37/src/license/gpl_cpe/license.txt000066400000000000000000000454771446271450100202540ustar00rootroot00000000000000The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. One line to give the program's name and a brief idea of what it does. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. The hypothetical commands 'show w' and 'show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than 'show w' and 'show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program 'Gnomovision' (which makes passes at compilers) written by James Hacker. signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. "CLASSPATH" EXCEPTION TO THE GPL Certain source files distributed by Oracle America and/or its affiliates are subject to the following clarification and special exception to the GPL, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the LICENSE file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.