forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test compiling against the newest arrow; Fix validity map; Add benchm…
…ark script Remove arrow-tools dependency changed zipWithIndex to while loop modified benchmark to work with Python2 timeit closes apache#13
- Loading branch information
1 parent
afd5739
commit a4b958e
Showing
6 changed files
with
82 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pyspark | ||
import timeit | ||
import random | ||
from pyspark.sql import SparkSession | ||
|
||
numPartition = 8 | ||
|
||
def time(df, repeat, number): | ||
print("toPandas with arrow") | ||
print(timeit.repeat(lambda: df.toPandas(True), repeat=repeat, number=number)) | ||
|
||
print("toPandas without arrow") | ||
print(timeit.repeat(lambda: df.toPandas(False), repeat=repeat, number=number)) | ||
|
||
def long(): | ||
return random.randint(0, 10000) | ||
|
||
def double(): | ||
return random.random() | ||
|
||
def genDataLocal(spark, size, columns): | ||
data = [list([fn() for fn in columns]) for x in range(0, size)] | ||
df = spark.createDataFrame(data) | ||
return df | ||
|
||
def genData(spark, size, columns): | ||
rdd = spark.sparkContext\ | ||
.parallelize(range(0, size), numPartition)\ | ||
.map(lambda _: [fn() for fn in columns]) | ||
df = spark.createDataFrame(rdd) | ||
return df | ||
|
||
if __name__ == "__main__": | ||
spark = SparkSession.builder.appName("ArrowBenchmark").getOrCreate() | ||
df = genData(spark, 1000 * 1000, [long, double]) | ||
df.cache() | ||
df.count() | ||
|
||
time(df, 10, 1) | ||
|
||
df.unpersist() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters