Performance - fanliao/go-plinq GitHub Wiki

性能对比测试

这里采用了github.com/ahmetalpbalkan/go-linq的非并行模式作为对比的依据,测试结果是采用go提供的benchmark统计得到的。

测试的CPU为Intel Atom Z3740D(4核 1.33GHZ), 操作系统为Win8.1,时间单位是ms。

性能对比测试结果

N = 100

Select Where Union Except Intersect Reverse Sum SkipWhile FirstBy
go-plinq 0.28 0.20 0.34 0.26 0.27 0.11 0.04 0.24 0.16
go-linq 0.25 0.19 0.29 0.24 0.30 0.06 0.02 0.18 0.18

N = 1000

Select Where Union Except Intersect Reverse Sum SkipWhile FirstBy
go-plinq 1.23 0.90 3.05 2.30 2.34 0.80 0.26 1.10 1.06
go-linq 2.28 1.66 2.88 2.55 3.33 0.57 0.24 1.86 1.73

N = 10000

Select Where Union Except Intersect Reverse Sum SkipWhile FirstBy
go-plinq 8.31 5.85 38.32 32.70 34.41 4.43 1.39 9.25 8.98
go-linq 22.54 16.46 34.73 25.48 33.17 5.69 2.39 17.78 18.24

N = 100000

Select Where Union Except Intersect Reverse Sum SkipWhile FirstBy
go-plinq 73.95 53.08 369.54 323.08 320.07 29.19 11.78 84.78 83.17
go-linq 225.83 148.52 353.72 265.69 351.72 53.32 22.47 183.17 168.85

N = 1000000

Select Where Union Except Intersect Reverse Sum SkipWhile FirstBy
go-plinq 758.12 563.03 3921.77 4277.29 4316.35 289.13 112.82 760.62 739.59
go-linq 2333.43 1380.03 3793.58 3125.60 4368.43 517.36 212.11 1636.41 1657.44

上面的测试结果中,Union、Intersect, Except的测试结果始终非常接近,这3个运算符基本都是串行的运算,OrderBy同样也是。

Join、Distinct没有列出对比结果,因为go-linq的实现采取了类似双重循环的算法,效率要低很多,所以无法表现出并行和串行的差异。

并行算法的加速比取决于许多因素。从测试结果看,当N>=10000时,Select和Where运算的加速比基本稳定在3,但如果在select和where的函数中加入更耗时的操作,加速比将能达到3.5左右。

⚠️ **GitHub.com Fallback** ⚠️