Hi Dario,

Thanks for bringing this up. The second time speed could be explained
by the caching that happens inside the methods package. If you are
able to come up with a smaller reproducible example, I would be happy
to help out.

Michael

On Mon, Nov 22, 2021 at 1:00 PM Dario Strbenac via Bioc-devel
<bioc-devel@r-project.org> wrote:
>
> Good day,
>
> I created two constructor methods for a generic function. One is for the 
> default empty constructor and the other is a constructor when any one or more 
> parameters is specified by the user. The method signatures are:
>
> 1. c("missing", "missing", "missing", "missing", "missing", "missing", 
> "missing", "missing"),
> 2. c("characterOrMissing", "numericOrMissing", "numericOrMissing", 
> "numericOrMissing", "numericOrMissing", "characterOrMissing", 
> "BiocParallelParamOrMissing", "numericOrMissing")
>
> The class unions are defined as you might expect.
>
> setClassUnion("characterOrMissing", c("character", "missing"))
> setClassUnion("numericOrMissing", c("numeric", "missing"))
> setClassUnion("BiocParallelParamOrMissing", c("BiocParallelParam", "missing"))
>
> The first method works as expected:
>
> > system.time(CrossValParams())
>    user  system elapsed
>   0.165   0.000   0.165
>
> The second takes over ten minutes and constantly uses 100% CPU usage, 
> according to top.
>
> > system.time(CrossValParams("Leave-k-Out", leave = 2))
>    user  system elapsed
> 760.018  15.093 775.090
>
> Strangely, if I rerun this code again, it works quickly the second time.
>
> > system.time(CrossValParams("Leave-k-Out", leave = 2))
>    user  system elapsed
>   0.145   0.000   0.145
>
> I haven't been able to come up with a minimal reproducile example of the 
> issue. How can this be done consistently and efficiently?
>
> --------------------------------------
> Dario Strbenac
> University of Sydney
> Camperdown NSW 2050
> Australia
> _______________________________________________
> Bioc-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel



-- 
Michael Lawrence
Principal Scientist, Director of Data Science and Statistical Computing
Genentech, A Member of the Roche Group
Office +1 (650) 225-7760
micha...@gene.com

Join Genentech on LinkedIn | Twitter | Facebook | Instagram | YouTube

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to