Skip to content

Commit 0551062

Browse files
committed
[auto] Reflect the changes of main repository.
0 parents  commit 0551062

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+18363
-0
lines changed

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Compiled class file
2+
*.class
3+
4+
# Log file
5+
*.log
6+
7+
# Package Files
8+
*.jar
9+
*.war
10+
*.nar
11+
*.ear
12+
*.zip
13+
*.tar.gz
14+
*.rar
15+
16+
# C/C++
17+
*.lib
18+
*.obj
19+
20+
# Virtual machine crash logs http://www.java.com/en/download/help/error_hotspot.xml
21+
hs_err_pid*
22+
replay_pid*
23+
*.hprof
24+
25+
# Node https://github.com/github/gitignore/blob/7ad34f7adba8546a19e3245e163e5502c338490a/Node.gitignore
26+
node_modules/
27+
28+
### Gradle
29+
30+
!/gradle/wrapper/**
31+
.gradle
32+
/build
33+
/out
34+
35+
# My settings @nyabkun
36+
.temp
37+
*gpr.key
38+
.q_*
39+
q_ignore
40+
/user
41+
/userHome

CallChainNodeHitCount.txt

Lines changed: 411 additions & 0 deletions
Large diffs are not rendered by default.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 nyabkun
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# 🐕 qq-benchmark
2+
3+
**qq-benchmark** is a Kotlin library that can benchmark your code snippets with beautiful console output.
4+
- Just copy and paste 🟦 Single-File version [QBenchmark.kt](src-single/QBenchmark.kt) into your project.
5+
- Or you can use 🟩 Split-File Jar version. See [Maven Dependency Section](#-split-file-jar-version-maven-dependency).
6+
- Feel free to fork or copy to your own codebase.
7+
8+
9+
10+
## 🟦 Single-File version Dependency
11+
12+
If you copy & paste [QBenchmark.kt](src-single/QBenchmark.kt).
13+
14+
Refer to [build.gradle.kts](build.gradle.kts) to directly check project settings.
15+
16+
17+
18+
```kotlin
19+
dependencies {
20+
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.20")
21+
}
22+
```
23+
24+
## 🟩 Split-File Jar version Maven Dependency
25+
26+
If you prefer a jar library. Add [jitpack.io](https://jitpack.io/#nyabkun/qq-benchmark) repository to the build script.
27+
28+
### build.gradle ( Groovy )
29+
```groovy
30+
repositories {
31+
...
32+
maven { url 'https://jitpack.io' }
33+
}
34+
35+
dependencies {
36+
implementation 'com.github.nyabkun:qq-benchmark:v2023-05-21'
37+
}
38+
```
39+
40+
### build.gradle.kts ( Kotlin )
41+
```kotlin
42+
repositories {
43+
...
44+
maven("https://jitpack.io")
45+
}
46+
47+
dependencies {
48+
implementation("com.github.nyabkun:qq-benchmark:v2023-05-21")
49+
}
50+
```
51+
52+
### pom.xml
53+
```xml
54+
<repositories>
55+
...
56+
<repository>
57+
<id>jitpack.io</id>
58+
<url>https://jitpack.io</url>
59+
</repository>
60+
</repositories>
61+
62+
<dependencies>
63+
...
64+
<dependency>
65+
<groupId>com.github.nyabkun</groupId>
66+
<artifactId>qq-benchmark</artifactId>
67+
<version>v2023-05-21</version>
68+
</dependency>
69+
</dependencies>
70+
```
71+
72+
## How did I create this library
73+
74+
I created this library by developing a program within my own codebase that automatically resolves dependencies at the method or property level, extracts necessary code elements, and generates a compact, self-contained, single-file library.
75+
76+
The program uses [PSI](https://plugins.jetbrains.com/docs/intellij/psi.html) to resolve dependencies for function calls and references to classes.
77+
78+
Although my original repository is currently disorganized, I have been gradually extracting and publishing small libraries. I also plan to prepare the original repository for publication in the future
79+

VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
v2023-05-21
2+
1e557b58a05561d20b2294114325bcf5e7513b817f1501fd63237906e867d1290acf27e323fca9287bf9dc4dc2b6e8225b7cc4dba581977bfa8045129f11bb65

build.gradle.kts

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
/*
2+
* Copyright 2023. nyabkun
3+
*
4+
* 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:
5+
*
6+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
*
8+
* 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.
9+
*/
10+
11+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
12+
13+
println("This Gradle script starts with -Dfile.encoding=" + System.getProperty("file.encoding"))
14+
15+
val qMavenArtifactId = "qq-benchmark"
16+
val qKotlinVersion = "1.8.20"
17+
val qJvmSourceCompatibility = "17"
18+
val qJvmTargetCompatibility = "17"
19+
20+
plugins {
21+
val kotlinVersion = "1.8.20"
22+
23+
application
24+
kotlin("jvm") version kotlinVersion
25+
kotlin("plugin.serialization") version kotlinVersion
26+
id("maven-publish")
27+
// id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
28+
}
29+
30+
group = "com.nyabkun.qol"
31+
32+
version = "v2023-05-21"
33+
34+
repositories {
35+
mavenCentral()
36+
maven("https://jitpack.io")
37+
}
38+
39+
java {
40+
toolchain {
41+
sourceCompatibility = JavaVersion.toVersion(qJvmSourceCompatibility)
42+
targetCompatibility = JavaVersion.toVersion(qJvmTargetCompatibility)
43+
}
44+
}
45+
46+
// https://www.youtube.com/watch?v=hSgPNbEcX98
47+
// https://github.com/search?q=%22ktlint+%7B%22+language%3Akotlin+path%3Abuild.gradle.kts&type=code
48+
// tasks.getByPath("build").dependsOn("ktlintFormat")
49+
// ktlint {
50+
// // ignoreFailures.set(false)
51+
// ignoreFailures.set(true)
52+
// disabledRules.set(listOf("final-newline", "no-wildcard-imports"))
53+
// reporters {
54+
// reporter(ReporterType.PLAIN)
55+
// reporter(ReporterType.CHECKSTYLE)
56+
// reporter(ReporterType.SARIF)
57+
// }
58+
// }
59+
60+
sourceSets.main {
61+
java.srcDirs("src-split")
62+
63+
resources.srcDirs("rsc")
64+
}
65+
66+
sourceSets.test {
67+
java.srcDirs("src-test-split")
68+
69+
resources.srcDirs("rsc-test")
70+
}
71+
72+
73+
74+
sourceSets.register("single") {
75+
java.srcDirs("src-single")
76+
}
77+
78+
val singleImplementation: Configuration by configurations.getting {
79+
extendsFrom(configurations.implementation.get())
80+
}
81+
82+
val singleRuntimeOnly: Configuration by configurations.getting {
83+
extendsFrom(configurations.runtimeOnly.get())
84+
}
85+
86+
sourceSets.register("testSingle") {
87+
java.srcDirs("src-test-single")
88+
89+
resources.srcDirs("rsc-test")
90+
}
91+
92+
val testSingleImplementation: Configuration by configurations.getting {
93+
extendsFrom(configurations.testImplementation.get())
94+
}
95+
96+
val testSingleRuntimeOnly: Configuration by configurations.getting {
97+
extendsFrom(configurations.testRuntimeOnly.get())
98+
}
99+
100+
dependencies {
101+
implementation("org.jetbrains.kotlin:kotlin-reflect:1.8.20")
102+
}
103+
104+
tasks {
105+
jar {
106+
enabled = true
107+
108+
archiveBaseName.set(qMavenArtifactId)
109+
110+
from(sourceSets.main.get().output)
111+
112+
manifest {
113+
attributes(
114+
"Implementation-Title" to qMavenArtifactId,
115+
"Implementation-Version" to project.version
116+
)
117+
}
118+
}
119+
120+
val qSrcJar by registering(Jar::class) {
121+
archiveBaseName.set(qMavenArtifactId)
122+
archiveClassifier.set("sources")
123+
from(sourceSets.main.get().allSource)
124+
}
125+
126+
artifacts {
127+
archives(qSrcJar)
128+
archives(jar)
129+
}
130+
131+
distZip {
132+
enabled = false
133+
}
134+
135+
distTar {
136+
enabled = false
137+
}
138+
139+
startScripts {
140+
enabled = false
141+
}
142+
143+
withType<JavaCompile>().configureEach {
144+
options.encoding = "UTF-8"
145+
}
146+
147+
withType<JavaExec>().configureEach {
148+
jvmArgs("-Dfile.encoding=UTF-8")
149+
}
150+
151+
withType<KotlinCompile>().configureEach {
152+
kotlinOptions.jvmTarget = JavaVersion.toVersion(qJvmTargetCompatibility).toString()
153+
}
154+
155+
register<JavaExec>("qRunTestSplit") {
156+
mainClass.set("nyab.util.QBenchmarkTestKt")
157+
classpath = sourceSets.get("test").runtimeClasspath
158+
}
159+
160+
register<JavaExec>("qRunTestSingle") {
161+
mainClass.set("QBenchmarkTestKt")
162+
classpath = sourceSets.get("testSingle").runtimeClasspath
163+
}
164+
165+
166+
167+
getByName<Test>("test") {
168+
dependsOn("qRunTestSingle")
169+
dependsOn("qRunTestSplit")
170+
}
171+
}
172+
173+
publishing {
174+
publications {
175+
create<MavenPublication>("maven") {
176+
artifactId = qMavenArtifactId
177+
178+
from(components["kotlin"])
179+
180+
artifact(tasks.getByName("qSrcJar")) {
181+
classifier = "sources"
182+
}
183+
}
184+
}
185+
// // GitHub Packages
186+
// repositories {
187+
// maven {
188+
// url = uri("https://maven.pkg.github.com/nyabkun/qq-benchmark")
189+
// credentials {
190+
// username = "nyabkun"
191+
// password = File("../../.q_gpr.key").readText(Charsets.UTF_8).trim()
192+
// }
193+
// }
194+
// }
195+
}

gradle/wrapper/gradle-wrapper.jar

60.6 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)