f2-IDCONTENT
`, "IDCONTENT", idContent), "IDFILENAME", idFilename))
}

func fsFromTxtTar(s string) afero.Fs {
	data := txtar.Parse([]byte(s))
	fs := afero.NewMemMapFs()
	for _, f := range data.Files {
		if err := afero.WriteFile(fs, f.Name, bytes.TrimSuffix(f.Data, []byte("\n")), 0666); err != nil {
			panic(err)
		}

	}
	return fs
}

type testFs struct {
	statErr error
}

func (fs *testFs) Stat(name string) (os.FileInfo, error) {
	return nil, fs.statErr
}

func (fs *testFs) LstatIfPossible(name string) (os.FileInfo, bool, error) {
	return nil, false, fs.statErr
}

func (fs *testFs) Name() string {
	return "testFs"
}

func (fs *testFs) Create(name string) (afero.File, error) {
	panic("not implemented")
}

func (fs *testFs) Mkdir(name string, perm os.FileMode) error {
	panic("not implemented")
}

func (fs *testFs) MkdirAll(path string, perm os.FileMode) error {
	panic("not implemented")
}

func (fs *testFs) Open(name string) (afero.File, error) {
	panic("not implemented")
}

func (fs *testFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error) {
	panic("not implemented")
}

func (fs *testFs) Remove(name string) error {
	panic("not implemented")
}

func (fs *testFs) RemoveAll(path string) error {
	panic("not implemented")
}

func (fs *testFs) Rename(oldname string, newname string) error {
	panic("not implemented")
}

func (fs *testFs) Chmod(name string, mode os.FileMode) error {
	panic("not implemented")
}

func (fs *testFs) Chown(name string, uid int, gid int) error {
	panic("not implemented")
}

func (fs *testFs) Chtimes(name string, atime time.Time, mtime time.Time) error {
	panic("not implemented")
}

func BenchmarkOverlayFs(b *testing.B) {
	fs1, fs2 := basicFs("1", "1"), basicFs("1", "2")
	ofs := New(Options{FirstWritable: true, Fss: []afero.Fs{fs1, fs2}})
	cfs := afero.NewCopyOnWriteFs(fs2, fs1)

	runBenchMark := func(fs afero.Fs, b *testing.B) {
		for i := 0; i < b.N; i++ {
			_, err := afero.ReadDir(fs, "mydir")
			if err != nil {
				b.Fatal(err)
			}
			f, err := fs.Open("mydir/f1-1.txt")
			if err != nil {
				b.Fatal(err)
			}
			f.Close()
			d, err := fs.Open("mydir")
			if err != nil {
				b.Fatal(err)
			}
			d.Close()
			_, err = ofs.Stat("mydir/f1-1.txt")
			if err != nil {
				b.Fatal(err)
			}
		}
	}

	b.Run("OverlayFs", func(b *testing.B) {
		runBenchMark(ofs, b)
	})

	b.Run("CopyOnWriteFs", func(b *testing.B) {
		runBenchMark(cfs, b)
	})

}
