```
library(pcalg)
## define parameters
p <- 10 # number of random variables
n <- 1000 # number of samples
szero <- 10 # expected number of edges in DAG
s <- szero / (p*(p-1)) # sparsness of the graph
## generate random data
# set.seed(42)
g <- randomDAG(p,s) # generate a random DAG
d <- rmvDAG(n,g, errDist="normal") # generate random samples
suppressWarnings({
gCPDAG <-
pcAlgo(d,alpha=0.05, directed=TRUE) # estimate of the CPDAG
})
(shd.val <- shd(g,gCPDAG))
```

I want to do such above codes 12 times. That is 12 runs simulation. Then I want to get the average value of shd.val.

I also want to compute the running time of these 12 simulations.

How to do these?