@@ -264,6 +264,7 @@ go test ./pbm/storage/s3 -bench=BenchmarkS3Upload -run=^$ -v \
264264-part-size=100
265265*/
266266func BenchmarkS3Upload (b * testing.B ) {
267+ var uploadTimes []time.Duration
267268 numThreds := max (runtime .GOMAXPROCS (0 ), 1 )
268269 fsize := * fileSize * 1024 * 1024
269270 pSize := * partSize * 1024 * 1024
@@ -289,6 +290,7 @@ func BenchmarkS3Upload(b *testing.B) {
289290 b .Logf ("aws s3 client: file size=%s; part size=%s; NumThreads=%d" ,
290291 storage .PrettySize (fsize ), storage .PrettySize (pSize ), numThreds )
291292
293+
292294 b .ResetTimer ()
293295 b .SetBytes (fsize )
294296
@@ -298,7 +300,6 @@ func BenchmarkS3Upload(b *testing.B) {
298300 r := io .LimitReader (infR , fsize )
299301
300302 fname := time .Now ().Format ("2006-01-02T15:04:05" )
301- b .Logf ("uploading file: %s ...." , fname )
302303
303304 putInput := & s3.PutObjectInput {
304305 Bucket : aws .String (bucket ),
@@ -308,15 +309,28 @@ func BenchmarkS3Upload(b *testing.B) {
308309 }
309310
310311 b .StartTimer ()
312+ startTime := time .Now ()
311313 _ , err := manager .NewUploader (s3Client , func (u * manager.Uploader ) {
312314 u .PartSize = pSize
313315 u .LeavePartsOnError = true
314316 u .Concurrency = numThreds
315317 }).Upload (context .Background (), putInput )
318+ uploadDuration := time .Since (startTime )
319+ uploadTimes = append (uploadTimes , uploadDuration )
320+ b .Logf ("uploading file: %s, completed in: %v" , fname , uploadDuration )
316321 if err != nil {
317322 b .Fatalf ("put object: %v" , err )
318323 }
319324 }
325+
326+ if len (uploadTimes ) > 0 {
327+ var totalDuration time.Duration
328+ for _ , duration := range uploadTimes {
329+ totalDuration += duration
330+ }
331+ averageTime := totalDuration / time .Duration (len (uploadTimes ))
332+ b .Logf ("average upload time: %v" , averageTime )
333+ }
320334}
321335
322336// BenchmarkS3StorageSave measures the performance of uploading file on the
0 commit comments