11use criterion:: { Criterion , Throughput } ;
2+ use ferrumc_macros:: block;
3+ use ferrumc_world:: block_id:: BlockId ;
24use ferrumc_world:: chunk_format:: Chunk ;
3- use ferrumc_world:: vanilla_chunk_format:: BlockData ;
45use rand:: Rng ;
56use std:: hint:: black_box;
67
@@ -44,32 +45,14 @@ pub(crate) fn bench_edits(c: &mut Criterion) {
4445 write_group. bench_with_input ( "Write 0,0,0" , & chunk, |b, chunk| {
4546 b. iter ( || {
4647 let mut chunk = chunk. clone ( ) ;
47- black_box ( chunk. set_block (
48- 0 ,
49- 0 ,
50- 0 ,
51- BlockData {
52- name : "minecraft:bricks" . to_string ( ) ,
53- properties : None ,
54- } ,
55- ) )
56- . unwrap ( ) ;
48+ black_box ( chunk. set_block ( 0 , 0 , 0 , block ! ( "bricks" ) ) ) . unwrap ( ) ;
5749 } ) ;
5850 } ) ;
5951
6052 write_group. bench_with_input ( "Write 8,8,150" , & chunk, |b, chunk| {
6153 b. iter ( || {
6254 let mut chunk = chunk. clone ( ) ;
63- black_box ( chunk. set_block (
64- 8 ,
65- 8 ,
66- 150 ,
67- BlockData {
68- name : "minecraft:bricks" . to_string ( ) ,
69- properties : None ,
70- } ,
71- ) )
72- . unwrap ( ) ;
55+ black_box ( chunk. set_block ( 8 , 8 , 150 , block ! ( "bricks" ) ) ) . unwrap ( ) ;
7356 } ) ;
7457 } ) ;
7558
@@ -80,10 +63,7 @@ pub(crate) fn bench_edits(c: &mut Criterion) {
8063 get_rand_in_range ( 0 , 15 ) ,
8164 get_rand_in_range ( 0 , 15 ) ,
8265 get_rand_in_range ( 0 , 255 ) ,
83- BlockData {
84- name : "minecraft:bricks" . to_string ( ) ,
85- properties : None ,
86- } ,
66+ block ! ( "bricks" ) ,
8767 ) )
8868 . unwrap ( ) ;
8969 } ) ;
@@ -94,11 +74,7 @@ pub(crate) fn bench_edits(c: &mut Criterion) {
9474 write_group. bench_with_input ( "Fill" , & chunk, |b, chunk| {
9575 b. iter ( || {
9676 let mut chunk = chunk. clone ( ) ;
97- black_box ( chunk. fill ( BlockData {
98- name : "minecraft:bricks" . to_string ( ) ,
99- properties : None ,
100- } ) )
101- . unwrap ( ) ;
77+ black_box ( chunk. fill ( block ! ( "bricks" ) ) ) . unwrap ( ) ;
10278 } ) ;
10379 } ) ;
10480
@@ -108,16 +84,7 @@ pub(crate) fn bench_edits(c: &mut Criterion) {
10884 for x in 0 ..16 {
10985 for y in 0 ..256 {
11086 for z in 0 ..16 {
111- black_box ( chunk. set_block (
112- x,
113- y,
114- z,
115- BlockData {
116- name : "minecraft:bricks" . to_string ( ) ,
117- properties : None ,
118- } ,
119- ) )
120- . unwrap ( ) ;
87+ black_box ( chunk. set_block ( x, y, z, block ! ( "bricks" ) ) ) . unwrap ( ) ;
12188 }
12289 }
12390 }
@@ -131,15 +98,7 @@ pub(crate) fn bench_edits(c: &mut Criterion) {
13198 for x in 0 ..16 {
13299 for y in 0 ..256 {
133100 for z in 0 ..16 {
134- batch. set_block (
135- x,
136- y,
137- z,
138- black_box ( BlockData {
139- name : "minecraft:bricks" . to_string ( ) ,
140- properties : None ,
141- } ) ,
142- ) ;
101+ batch. set_block ( x, y, z, black_box ( block ! ( "bricks" ) ) ) ;
143102 }
144103 }
145104 }
@@ -155,19 +114,11 @@ pub(crate) fn bench_edits(c: &mut Criterion) {
155114 for y in 0 ..256 {
156115 for z in 0 ..16 {
157116 let block = if ( x + y + z) % 2 == 0 {
158- "minecraft: bricks"
117+ block ! ( " bricks")
159118 } else {
160- "minecraft: stone"
119+ block ! ( " stone")
161120 } ;
162- batch. set_block (
163- x,
164- y,
165- z,
166- black_box ( BlockData {
167- name : block. to_string ( ) ,
168- properties : None ,
169- } ) ,
170- ) ;
121+ batch. set_block ( x, y, z, black_box ( block) ) ;
171122 }
172123 }
173124 }
0 commit comments