how can I know how many time the system.gc will take?
how many time it take in the most of the times?

system.gc is just a request to collect garbage, it won't invoke it immediately. And how long it takes depends on how much memory you have that is available for collection - not much = fast, lots = slow.

Hence this is a very difficult to reliably time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.