@@ -221,3 +221,96 @@ func BenchmarkFs_WriteAtomic_1KB(b *B) {
221221 fsSinkResult = fs .WriteAtomic ("w.bin" , content )
222222 }
223223}
224+
225+ // --- Append / Stream ---
226+
227+ func BenchmarkFs_Append_Small (b * B ) {
228+ fs := fsBenchFixture (b , map [string ]int {"appendme.txt" : 0 })
229+ b .ReportAllocs ()
230+ for i := 0 ; i < b .N ; i ++ {
231+ fsSinkResult = fs .Append ("appendme.txt" )
232+ if fsSinkResult .OK {
233+ CloseStream (fsSinkResult .Value )
234+ }
235+ }
236+ }
237+
238+ func BenchmarkFs_ReadStream (b * B ) {
239+ fs := fsBenchFixture (b , map [string ]int {"stream.bin" : 4096 })
240+ b .ReportAllocs ()
241+ for i := 0 ; i < b .N ; i ++ {
242+ fsSinkResult = fs .ReadStream ("stream.bin" )
243+ if fsSinkResult .OK {
244+ CloseStream (fsSinkResult .Value )
245+ }
246+ }
247+ }
248+
249+ // --- EnsureDir / DeleteAll / Rename ---
250+
251+ func BenchmarkFs_EnsureDir_Exists (b * B ) {
252+ fs := fsBenchFixture (b , map [string ]int {})
253+ b .ReportAllocs ()
254+ for i := 0 ; i < b .N ; i ++ {
255+ fsSinkResult = fs .EnsureDir ("models" )
256+ }
257+ }
258+
259+ func BenchmarkFs_EnsureDir_Create (b * B ) {
260+ fs := fsBenchFixture (b , map [string ]int {})
261+ b .ReportAllocs ()
262+ for i := 0 ; i < b .N ; i ++ {
263+ // Cycle the same dir so the bench captures the make-then-noop floor.
264+ fsSinkResult = fs .EnsureDir ("ephemeral" )
265+ }
266+ }
267+
268+ func BenchmarkFs_DeleteAll (b * B ) {
269+ fs := fsBenchFixture (b , map [string ]int {})
270+ b .ReportAllocs ()
271+ for i := 0 ; i < b .N ; i ++ {
272+ fs .EnsureDir ("nuked" )
273+ fsSinkResult = fs .DeleteAll ("nuked" )
274+ }
275+ }
276+
277+ func BenchmarkFs_Rename (b * B ) {
278+ fs := fsBenchFixture (b , map [string ]int {"rename-src.bin" : 16 })
279+ b .ReportAllocs ()
280+ for i := 0 ; i < b .N ; i ++ {
281+ fsSinkResult = fs .Rename ("rename-src.bin" , "rename-dst.bin" )
282+ if fsSinkResult .OK {
283+ // Cycle back so the next iteration has the src again.
284+ fs .Rename ("rename-dst.bin" , "rename-src.bin" )
285+ }
286+ }
287+ }
288+
289+ // --- NewUnrestricted ---
290+
291+ func BenchmarkFs_NewUnrestricted (b * B ) {
292+ parent := fsBenchFixture (b , map [string ]int {})
293+ b .ReportAllocs ()
294+ for i := 0 ; i < b .N ; i ++ {
295+ _ = parent .NewUnrestricted ()
296+ }
297+ }
298+
299+ // --- ReadDir / ReadFSFile (the embed-side helpers) ---
300+
301+ func BenchmarkFs_ReadDir_FS (b * B ) {
302+ fsys := DirFS ("." )
303+ b .ReportAllocs ()
304+ for i := 0 ; i < b .N ; i ++ {
305+ fsSinkResult = ReadDir (fsys , "." )
306+ }
307+ }
308+
309+ func BenchmarkFs_ReadFSFile (b * B ) {
310+ fs := fsBenchFixture (b , map [string ]int {"r.bin" : 1024 })
311+ fsys := DirFS (fs .Root ())
312+ b .ReportAllocs ()
313+ for i := 0 ; i < b .N ; i ++ {
314+ fsSinkResult = ReadFSFile (fsys , "r.bin" )
315+ }
316+ }
0 commit comments