Skip to content

Commit b7ac8ad

Browse files
authored
Merge pull request #157 from neeleshpoli/master
Format numbers and dates per region
2 parents f14b9b1 + a7d786b commit b7ac8ad

File tree

4 files changed

+125
-68
lines changed

4 files changed

+125
-68
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script setup>
2+
import { computed, getCurrentInstance } from 'vue';
3+
4+
const props = defineProps({
5+
d: {
6+
type: Date,
7+
required: true
8+
}
9+
});
10+
11+
const formattedDateTime = computed(() => {
12+
return getCurrentInstance().appContext.config.globalProperties.$dateTimeFormatter.format(props.d);
13+
});
14+
</script>
15+
16+
17+
<template>
18+
{{ formattedDateTime }}
19+
</template>

docs/.vitepress/components/FmtNum.vue

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script setup>
2+
import { computed, getCurrentInstance } from 'vue';
3+
4+
const props = defineProps({
5+
n: {
6+
type: Number,
7+
required: true
8+
}
9+
});
10+
11+
const formattedNumber = computed(() => {
12+
return getCurrentInstance().appContext.config.globalProperties.$numberFormatter.format(props.n);
13+
});
14+
</script>
15+
16+
<template>
17+
{{ formattedNumber }}
18+
</template>

docs/.vitepress/theme/index.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { h } from 'vue'
33
import type { Theme } from 'vitepress'
44
import DefaultTheme from 'vitepress/theme'
55
import './style.css'
6+
import FmtNum from '../components/FmtNum.vue'
7+
import FmtDateTime from '../components/FmtDateTime.vue'
68

79
export default {
810
extends: DefaultTheme,
@@ -12,6 +14,16 @@ export default {
1214
})
1315
},
1416
enhanceApp({ app, router, siteData }) {
15-
// ...
17+
app.config.globalProperties.$numberFormatter = new Intl.NumberFormat(navigator.languages);
18+
app.config.globalProperties.$dateTimeFormatter = new Intl.DateTimeFormat(navigator.languages, {
19+
year: "numeric",
20+
month: "long",
21+
day: "numeric",
22+
hour: "numeric",
23+
minute: "numeric",
24+
timeZoneName: "short"
25+
});
26+
app.component('FmtNum', FmtNum);
27+
app.component('FmtDateTime', FmtDateTime);
1628
}
1729
} satisfies Theme

docs/about/benchmarks.md

+75-67
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
## Benchmarks
1+
# Benchmarks
22

3-
Here, I compare common Minecraft servers against Pumpkin.
3+
Here, common Minecraft servers are compared against Pumpkin.
44

5-
Is this comparison fair? Not really. While Pumpkin currently has far fewer features than other servers, which might suggest it uses fewer resources, it's important to consider that other servers have had years for optimization. Especially vanilla forks, which don’t need to rewrite the entire vanilla logic, can focus exclusively on optimizations.
6-
7-
ALL TESTS HAVE BEEN RAN MULTIPLE TIMES TO GUARANTEE CONSISTENT RESULTS
8-
9-
ALL PLAYERS DID NOT MOVE WHEN SPAWNING, ONLY THE INITIAL 8 CHUNKS WERE LOADED, THAT'S ALSO THE REASON CPU MAX IS USUALLY HIGH ON THE FIRST PLAYER
10-
ALL SERVERS USED THEIR OWN TERRAIN GENERATION, NO WORLD WAS PRE-LOADED
5+
> [!CAUTION]
6+
> **This comparison is unfair.** Pumpkin currently has far fewer features than other servers, which might suggest it uses fewer resources.
7+
> It's also important to consider that other servers have had years for optimization.
8+
> Vanilla forks, which don’t need to rewrite the entire vanilla logic, can focus exclusively on optimizations.
119
1210
![Screenshot From 2024-10-15 16-42-53](https://github.com/user-attachments/assets/e08fbb00-42fe-4479-a03b-11bb6886c91a)
1311

@@ -50,40 +48,48 @@ ALL SERVERS USED THEIR OWN TERRAIN GENERATION, NO WORLD WAS PRE-LOADED
5048

5149
<sub><sup>online mode was disabled for easier testing with non-premium accounts</sup></sub>
5250

51+
> [!NOTE]
52+
> All tests have been ran multiple times to guarantee consistent results.
53+
> All players did not move when spawning, only the initial 8 chunks were loaded.
54+
> All servers used their own terrain generation, no world was pre-loaded.
55+
56+
> [!IMPORTANT]
57+
> `CPU Max` is usually higher with one player as the initial chunks are being loaded.
58+
5359
## Pumpkin
5460

5561
Build: [8febc50](https://github.com/Snowiiii/Pumpkin/commit/8febc5035d5611558c13505b7724e6ca284e0ada)
5662

57-
Compile args:`--release`
63+
Compile args: `--release`
5864

5965
Run args:
6066

61-
**File Size:** 12,3MB
67+
**File Size:** <FmtNum :n=12.3 />MB
6268

63-
**Startup time:** 8ms
69+
**Startup time:** <FmtNum :n=8 />ms
6470

65-
**Shutdown time:** 0ms
71+
**Shutdown time:** <FmtNum :n=0 />ms
6672

67-
| Players | RAM | CPU idle | CPU Max |
68-
| ------- | ------- | -------- | ------- |
69-
| 0 | 392,2KB | 0,0% | 0,0% |
70-
| 1 | 24,9MB | 0,0% | 4,0% |
71-
| 2 | 25,1MB | 0,0% | 0,6% |
72-
| 5 | 26,0MB | 0,0% | 1,0% |
73-
| 10 | 27,1MB | 0,0% | 1,5% |
73+
| Players | RAM | CPU Idle | CPU Max |
74+
| ------- | --------------------- | ---------------- | ------------------ |
75+
| 0 | <FmtNum :n=392.2 />KB | <FmtNum :n=0 />% | <FmtNum :n=0 />% |
76+
| 1 | <FmtNum :n=24.9 />MB | <FmtNum :n=0 />% | <FmtNum :n=4 />% |
77+
| 2 | <FmtNum :n=25.1 />MB | <FmtNum :n=0 />% | <FmtNum :n=0.6 />% |
78+
| 5 | <FmtNum :n=26 />MB | <FmtNum :n=0 />% | <FmtNum :n=1 />% |
79+
| 10 | <FmtNum :n=27.1 />MB | <FmtNum :n=0 />% | <FmtNum :n=1.5 />% |
7480

75-
<sub><sup>pumpkin does cache already loaded chunks, resulting in no extra RAM usage besides player data and minimal CPU usage</sup></sub>
81+
<sub><sup>Pumpkin does cache already loaded chunks, resulting in no extra RAM usage besides player data and minimal CPU usage.</sup></sub>
7682

7783
#### Compile time
78-
Compiling from Nothing
84+
Compiling from Nothing:
7985

80-
**Debug:** 10.35sec
81-
**Release:** 38.40sec
86+
**Debug:** <FmtNum :n=10.35 />sec
87+
**Release:** <FmtNum :n=38.40 />sec
8288

83-
Recompilation (pumpkin crate)
89+
Recompilation (pumpkin crate):
8490

85-
**Debug:** 1.82sec
86-
**Release:** 28.68sec
91+
**Debug:** <FmtNum :n=1.82 />sec
92+
**Release:** <FmtNum :n=28.68 />sec
8793

8894
## Vanilla
8995

@@ -93,19 +99,19 @@ Compile args:
9399

94100
Run args: `nogui`
95101

96-
**File Size:** 51,6MB
102+
**File Size:** <FmtNum :n=51.6 />MB
97103

98-
**Startup time:** 7sec
104+
**Startup time:** <FmtNum :n=7 />sec
99105

100-
**Shutdown time:** 4sec
106+
**Shutdown time:** <FmtNum :n=4 />sec
101107

102-
| Players | RAM | CPU idle | CPU Max |
103-
| ------- | ----- | -------- | ------- |
104-
| 0 | 860MB | 0,1-0,3% | 51,0% |
105-
| 1 | 1.5GB | 0,9-1% | 41,0% |
106-
| 2 | 1.6GB | 1,0-1,1% | 10,0% |
107-
| 5 | 1.8GB | 2,0% | 20,0% |
108-
| 10 | 2,2GB | 4,0% | 24,0% |
108+
| Players | RAM | CPU idle | CPU Max |
109+
| ------- | --------------------- | ---------------------------------------- | ------------------ |
110+
| 0 | <FmtNum n="860" />MB | <FmtNum n="0.1" /> - <FmtNum n="0.3" />% | <FmtNum n="51" />% |
111+
| 1 | <FmtNum n="1.5" />GB | <FmtNum n="0.9" /> - <FmtNum n="1" />% | <FmtNum n="41" />% |
112+
| 2 | <FmtNum n="1.6" />GB | <FmtNum n="1" /> - <FmtNum n="1.1" />% | <FmtNum n="10" />% |
113+
| 5 | <FmtNum n="1.8" />GB | <FmtNum n="2" />% | <FmtNum n="20" />% |
114+
| 10 | <FmtNum n="2.2" />GB | <FmtNum n="4" />% | <FmtNum n="24" />% |
109115

110116
## Paper
111117

@@ -115,19 +121,20 @@ Compile args:
115121

116122
Run args: `nogui`
117123

118-
**File Size:** 49,4MB
124+
**File Size:** <FmtNum :n=49.4 />MB
125+
126+
**Startup time:** <FmtNum :n=7 />sec
119127

120-
**Startup time:** 7sec
128+
**Shutdown time:** <FmtNum :n=3 />sec
121129

122-
**Shutdown time:** 3sec
130+
| Players | RAM | CPU idle | CPU Max |
131+
| ------- | ------------------- | -------------------------------------- | ----------------- |
132+
| 0 | <FmtNum :n=1.1 />GB | <FmtNum :n=0.2 /> - <FmtNum :n=0.3 />% | <FmtNum :n=36 />% |
133+
| 1 | <FmtNum :n=1.7 />GB | <FmtNum :n=0.9 /> - <FmtNum :n=1.0 />% | <FmtNum :n=47 />% |
134+
| 2 | <FmtNum :n=1.8 />GB | <FmtNum :n=1 /> - <FmtNum :n=1.1 />% | <FmtNum :n=10 />% |
135+
| 5 | <FmtNum :n=1.9 />GB | <FmtNum :n=1.5 />% | <FmtNum :n=15 />% |
136+
| 10 | <FmtNum :n=2 />GB | <FmtNum :n=3 />% | <FmtNum :n=20 />% |
123137

124-
| Players | RAM | CPU idle | CPU Max |
125-
| ------- | ----- | -------- | ------- |
126-
| 0 | 1.1GB | 0,2-0,3% | 36,0% |
127-
| 1 | 1.7GB | 0,9-1,0% | 47,0% |
128-
| 2 | 1.8GB | 1-1-1,0% | 10,0% |
129-
| 5 | 1.9GB | 1.5% | 15,0% |
130-
| 10 | 2GB | 3,0% | 20,0% |
131138

132139
## Purpur
133140

@@ -137,19 +144,19 @@ Compile args:
137144

138145
Run args: `nogui`
139146

140-
**File Size:** 53,1MB
147+
**File Size:** <FmtNum :n=53.1 />MB
141148

142-
**Startup time:** 8sec
149+
**Startup time:** <FmtNum :n=8 />sec
143150

144-
**Shutdown time:** 4sec
151+
**Shutdown time:** <FmtNum :n=4 />sec
145152

146-
| Players | RAM | CPU idle | CPU Max |
147-
| ------- | ----- | -------- | ------- |
148-
| 0 | 1.4GB | 0,2-0,3% | 25,0% |
149-
| 1 | 1.6GB | 0,7-1,0% | 35,0% |
150-
| 2 | 1.7GB | 1,1-1,3% | 9,0% |
151-
| 5 | 1.9GB | 1.6% | 20,0% |
152-
| 10 | 2.2GB | 2-2,5,0% | 26,0% |
153+
| Players | RAM | CPU idle | CPU Max |
154+
| ------- | ------------------- | -------------------------------------- | ----------------- |
155+
| 0 | <FmtNum :n=1.4 />GB | <FmtNum :n=0.2 /> - <FmtNum :n=0.3 />% | <FmtNum :n=25 />% |
156+
| 1 | <FmtNum :n=1.6 />GB | <FmtNum :n=0.7 /> - <FmtNum :n=1.0 />% | <FmtNum :n=35 />% |
157+
| 2 | <FmtNum :n=1.7 />GB | <FmtNum :n=1.1 /> - <FmtNum :n=1.3 />% | <FmtNum :n=9 />% |
158+
| 5 | <FmtNum :n=1.9 />GB | <FmtNum :n=1.6 />% | <FmtNum :n=20 />% |
159+
| 10 | <FmtNum :n=2.2 />GB | <FmtNum :n=2 /> - <FmtNum :n=2.5 />% | <FmtNum :n=26 />% |
153160

154161
## Minestom
155162

@@ -161,20 +168,21 @@ Run args:
161168

162169
**Language:** Benchmarks ran with Kotlin 2.0.0 (Minestom itself is made with Java)
163170

164-
**File Size:** 2,8MB (Library)
171+
**File Size:** <FmtNum :n=2.8 />MB (Library)
165172

166-
**Startup time:** 310ms
173+
**Startup time:** <FmtNum :n=310 />ms
167174

168-
**Shutdown time:** 0ms
175+
**Shutdown time:** <FmtNum :n=0 />ms
169176

170177
<sub>[Used example code from](https://minestom.net/docs/setup/your-first-server)</sub>
171178

172-
| Players | RAM | CPU idle | CPU Max |
173-
| ------- | ----- | -------- | ------- |
174-
| 0 | 228MB | 0,1-0,3% | 1,0% |
175-
| 1 | 365MB | 0,9-1,0% | 5,0% |
176-
| 2 | 371MB | 1-1,1% | 4,0% |
177-
| 5 | 390MB | 1,0% | 6,0% |
178-
| 10 | 421MB | 3,0% | 9,0% |
179+
| Players | RAM | CPU idle | CPU Max |
180+
| ------- | ------------------- | -------------------------------------- | ---------------- |
181+
| 0 | <FmtNum :n=228 />MB | <FmtNum :n=0.1 /> - <FmtNum :n=0.3 />% | <FmtNum :n=1 />% |
182+
| 1 | <FmtNum :n=365 />MB | <FmtNum :n=0.9 /> - <FmtNum :n=1.0 />% | <FmtNum :n=5 />% |
183+
| 2 | <FmtNum :n=371 />MB | <FmtNum :n=1 /> - <FmtNum :n=1.1 />% | <FmtNum :n=4 />% |
184+
| 5 | <FmtNum :n=390 />MB | <FmtNum :n=1.0 />% | <FmtNum :n=6 />% |
185+
| 10 | <FmtNum :n=421 />MB | <FmtNum :n=3 />% | <FmtNum :n=9 />% |
186+
179187

180-
Benchmarked at 15.10.2024 18:34 (UTC+2)
188+
Benchmarked at <FmtDateTime :d="new Date('2024-10-15T16:34Z')" />

0 commit comments

Comments
 (0)