Changes between Initial Version and Version 1 of OptimizingNetworkAdjacencyMatrix


Ignore:
Timestamp:
05/29/14 14:19:05 (5 years ago)
Author:
jrhorner
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OptimizingNetworkAdjacencyMatrix

    v1 v1  
     1{{{ 
     2library(ggplot2) 
     3library(microbenchmark) 
     4library(network) 
     5library(ergm) 
     6data('faux.magnolia.high') 
     7fmh <- faux.magnolia.high 
     8}}} 
     9 
     10Since researching ticket #866, I accidentally started benchmarking as.matrix.network.adjacency which has nothing to do with the ticket. Regardless, I wanted to capture some of the attempts at doing so. Code can be found in my devolper branch [12933/statnet_commons]. 
     11 
     12In the following tests, I compare the run-time of functions orig() and proposed(). orig() always represents the original code and proposed() always represents the attempted optimized code. 
     13 
     14Results of setting an edge attribute of type character: 
     15 
     16 
     17{{{ 
     18set.edge.attribute(fmh,'dummy','foo') 
     19orig <- function() as.matrix.network.adjacency.orig(fmh,'dummy') 
     20proposed <- function() as.matrix.network.adjacency(fmh,'dummy') 
     21res <- microbenchmark(orig(),proposed(),times=100) 
     22summary(res) 
     23}}} 
     24 
     25{{{ 
     26##         expr    min     lq median     uq  max neval 
     27## 1     orig() 1446.9 1469.7 1480.5 1582.0 1751   100 
     28## 2 proposed()  525.7  544.6  549.5  556.3 1546   100 
     29}}} 
     30 
     31{{{ 
     32qplot(y=time,colour=expr,data=res) 
     33}}} 
     34 
     35[[Image(unnamed-chunk-3.png)]] 
     36 
     37Results of setting an edge attribute of type numeric: 
     38 
     39 
     40{{{ 
     41set.edge.attribute(fmh,'dummy',2) 
     42orig <- function() as.matrix.network.adjacency.orig(fmh,'dummy') 
     43proposed <- function() as.matrix.network.adjacency(fmh,'dummy') 
     44res <- microbenchmark(orig(),proposed(),times=100) 
     45summary(res) 
     46}}} 
     47 
     48{{{ 
     49##         expr   min    lq median    uq   max neval 
     50## 1     orig() 309.4 420.9  424.7 428.2 653.8   100 
     51## 2 proposed() 280.5 387.0  390.3 394.7 613.8   100 
     52}}} 
     53 
     54{{{ 
     55qplot(y=time,colour=expr,data=res) 
     56}}} 
     57 
     58[[Image(unnamed-chunk-5.png)]] 
     59 
     60Results of setting an edge attribute of type integer: 
     61 
     62 
     63{{{ 
     64set.edge.attribute(fmh,'dummy',3L) 
     65orig <- function() as.matrix.network.adjacency.orig(fmh,'dummy') 
     66proposed <- function() as.matrix.network.adjacency(fmh,'dummy') 
     67res <- microbenchmark(orig(),proposed(),times=100) 
     68summary(res) 
     69}}} 
     70 
     71{{{ 
     72##         expr   min    lq median    uq   max neval 
     73## 1     orig() 306.5 420.6  423.8 430.6 771.9   100 
     74## 2 proposed() 269.7 381.9  384.4 389.1 493.0   100 
     75}}} 
     76 
     77{{{ 
     78qplot(y=time,colour=expr,data=res) 
     79}}} 
     80 
     81[[Image(unnamed-chunk-7.png)]]