yaooqinn commented on code in PR #44849:
URL: https://github.com/apache/spark/pull/44849#discussion_r1464211489


##########
connector/avro/src/test/scala/org/apache/spark/sql/execution/benchmark/AvroWriteBenchmark.scala:
##########
@@ -52,12 +54,48 @@ object AvroWriteBenchmark extends DataSourceWriteBenchmark {
         // cache the data to ensure we are not benchmarking range or 
repartition
         df.noop()
         df.createOrReplaceTempView("t1")
-        val benchmark = new Benchmark(s"Write wide rows into $files files", 
values, output = output)
-        benchmark.addCase("Write wide rows") { _ =>
-          spark.sql("SELECT * FROM t1").
-            
write.format("avro").save(s"${dir.getCanonicalPath}/${Random.nextLong().abs}")
+
+        def addBenchmark(
+            benchmark: Benchmark,
+            codec: String,
+            conf: Map[String, String] = Map.empty): Unit = {
+          val name = conf.map(kv => kv._1.stripPrefix("spark.sql.avro.") + "=" 
+ kv._2)
+            .mkString(codec + ": ", ", ", "")
+          benchmark.addCase(name) { _ =>
+            withSQLConf(conf.toSeq: _*) {
+              spark
+                .table("t1")
+                .write
+                .option("compression", codec)
+                .format("avro")
+                .save(s"${dir.getCanonicalPath}/${Random.nextLong().abs}")
+            }
+          }
+        }
+
+        val bm = new Benchmark(s"Avro compression with different codec", 
values, output = output)
+        AvroCompressionCodec.values().sortBy(_.getCodecName).foreach { codec =>
+          addBenchmark(bm, codec.name)
+        }
+        bm.run()
+
+        
AvroCompressionCodec.values().filter(_.getSupportCompressionLevel).foreach { 
codec =>
+          val bm = new Benchmark(
+            s"Avro ${codec.getCodecName} with different levels", values, 
output = output)
+          Seq(1, 3, 5, 7, 9).foreach { level =>
+            val conf = Map(s"spark.sql.avro.${codec.getCodecName}.level" -> 
level.toString)
+            addBenchmark(bm, codec.name, conf)
+            if (codec == AvroCompressionCodec.ZSTANDARD) {
+              val nondft =

Review Comment:
   Yes, I hope the name doesn't bother you too much.:)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to