@@ -73,11 +73,13 @@ RUN cp /etc/foo /etc/bar
7373 fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
7474 fstest .CreateFile ("foo" , []byte ("foo" ), 0600 ),
7575 )
76- b .StartTimer ()
77- out , err := buildxBuildCmd (sb , withArgs (dir ))
78- b .StopTimer ()
79- sb .WriteLogFile (b , "buildx" , []byte (out ))
80- require .NoError (b , err , out )
76+ reportBuildkitdAlloc (b , sb , func () {
77+ b .StartTimer ()
78+ out , err := buildxBuildCmd (sb , withArgs (dir ))
79+ b .StopTimer ()
80+ sb .WriteLogFile (b , "buildx" , []byte (out ))
81+ require .NoError (b , err , out )
82+ })
8183}
8284
8385func benchmarkBuildMultistage (b * testing.B , sb testutil.Sandbox ) {
@@ -94,11 +96,13 @@ COPY --from=base /etc/bar /bar
9496 fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
9597 fstest .CreateFile ("foo" , []byte ("foo" ), 0600 ),
9698 )
97- b .StartTimer ()
98- out , err := buildxBuildCmd (sb , withArgs (dir ))
99- b .StopTimer ()
100- sb .WriteLogFile (b , "buildx" , []byte (out ))
101- require .NoError (b , err , out )
99+ reportBuildkitdAlloc (b , sb , func () {
100+ b .StartTimer ()
101+ out , err := buildxBuildCmd (sb , withArgs (dir ))
102+ b .StopTimer ()
103+ sb .WriteLogFile (b , "buildx" , []byte (out ))
104+ require .NoError (b , err , out )
105+ })
102106}
103107
104108// https://github.com/docker/buildx/issues/2479
@@ -112,22 +116,26 @@ RUN --mount=type=secret,id=SECRET cat /run/secrets/SECRET
112116 fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
113117 fstest .CreateFile ("secret.txt" , []byte ("mysecret" ), 0600 ),
114118 )
115- b .StartTimer ()
116- out , err := buildxBuildCmd (sb , withDir (dir ), withArgs ("--secret=id=SECRET,src=secret.txt" , "." ))
117- b .StopTimer ()
118- sb .WriteLogFile (b , "buildx" , []byte (out ))
119- require .NoError (b , err , out )
119+ reportBuildkitdAlloc (b , sb , func () {
120+ b .StartTimer ()
121+ out , err := buildxBuildCmd (sb , withDir (dir ), withArgs ("--secret=id=SECRET,src=secret.txt" , "." ))
122+ b .StopTimer ()
123+ sb .WriteLogFile (b , "buildx" , []byte (out ))
124+ require .NoError (b , err , out )
125+ })
120126}
121127
122128func benchmarkBuildRemote (b * testing.B , sb testutil.Sandbox ) {
123- b .StartTimer ()
124- out , err := buildxBuildCmd (sb , withArgs (
125- "--build-arg=BUILDKIT_SYNTAX=" + dockerfileImagePin ,
126- "https://github.com/dvdksn/buildme.git#eb6279e0ad8a10003718656c6867539bd9426ad8" ,
127- ))
128- b .StopTimer ()
129- sb .WriteLogFile (b , "buildx" , []byte (out ))
130- require .NoError (b , err , out )
129+ reportBuildkitdAlloc (b , sb , func () {
130+ b .StartTimer ()
131+ out , err := buildxBuildCmd (sb , withArgs (
132+ "--build-arg=BUILDKIT_SYNTAX=" + dockerfileImagePin ,
133+ "https://github.com/dvdksn/buildme.git#eb6279e0ad8a10003718656c6867539bd9426ad8" ,
134+ ))
135+ b .StopTimer ()
136+ sb .WriteLogFile (b , "buildx" , []byte (out ))
137+ require .NoError (b , err , out )
138+ })
131139}
132140
133141func benchmarkBuildHighParallelization16x (b * testing.B , sb testutil.Sandbox ) {
@@ -165,9 +173,11 @@ RUN cp /etc/foo /etc/bar
165173 require .NoError (b , err , out )
166174 }()
167175 }
168- b .StartTimer ()
169- wg .Wait ()
170- b .StopTimer ()
176+ reportBuildkitdAlloc (b , sb , func () {
177+ b .StartTimer ()
178+ wg .Wait ()
179+ b .StopTimer ()
180+ })
171181}
172182
173183func benchmarkBuildFileTransfer (b * testing.B , sb testutil.Sandbox ) {
@@ -181,11 +191,13 @@ RUN du -sh . && tree .
181191 fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
182192 contextDirApplier ,
183193 )
184- b .StartTimer ()
185- out , err := buildxBuildCmd (sb , withArgs (dir ))
186- b .StopTimer ()
187- sb .WriteLogFile (b , "buildx" , []byte (out ))
188- require .NoError (b , err , out )
194+ reportBuildkitdAlloc (b , sb , func () {
195+ b .StartTimer ()
196+ out , err := buildxBuildCmd (sb , withArgs (dir ))
197+ b .StopTimer ()
198+ sb .WriteLogFile (b , "buildx" , []byte (out ))
199+ require .NoError (b , err , out )
200+ })
189201}
190202
191203// https://github.com/moby/buildkit/pull/4949
@@ -214,15 +226,17 @@ RUN uname -a
214226` , busyboxImage ))
215227
216228 dir := tmpdir (b , fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ))
217- b .StartTimer ()
218- out , err := buildxBuildCmd (sb , withArgs (
219- "--build-arg" , "BUILDKIT_DOCKERFILE_CHECK=skip=all" , // skip all checks (for InvalidBaseImagePlatform): https://docs.docker.com/build/checks/#skip-checks
220- "--platform" , platforms .Format (platform ),
221- dir ,
222- ))
223- b .StopTimer ()
224- sb .WriteLogFile (b , "buildx" , []byte (out ))
225- require .NoError (b , err , out )
229+ reportBuildkitdAlloc (b , sb , func () {
230+ b .StartTimer ()
231+ out , err := buildxBuildCmd (sb , withArgs (
232+ "--build-arg" , "BUILDKIT_DOCKERFILE_CHECK=skip=all" , // skip all checks (for InvalidBaseImagePlatform): https://docs.docker.com/build/checks/#skip-checks
233+ "--platform" , platforms .Format (platform ),
234+ dir ,
235+ ))
236+ b .StopTimer ()
237+ sb .WriteLogFile (b , "buildx" , []byte (out ))
238+ require .NoError (b , err , out )
239+ })
226240}
227241
228242func benchmarkBuildExportUncompressed (b * testing.B , sb testutil.Sandbox ) {
@@ -247,9 +261,11 @@ COPY . .
247261 fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
248262 contextDirApplier ,
249263 )
250- b .StartTimer ()
251- out , err := buildxBuildCmd (sb , withArgs ("--output=type=image,compression=" + compression , dir ))
252- b .StopTimer ()
253- sb .WriteLogFile (b , "buildx" , []byte (out ))
254- require .NoError (b , err , out )
264+ reportBuildkitdAlloc (b , sb , func () {
265+ b .StartTimer ()
266+ out , err := buildxBuildCmd (sb , withArgs ("--output=type=image,compression=" + compression , dir ))
267+ b .StopTimer ()
268+ sb .WriteLogFile (b , "buildx" , []byte (out ))
269+ require .NoError (b , err , out )
270+ })
255271}
0 commit comments