Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch usage from os.*File.Readdir to os.*File.ReadDir. #1105

Merged
merged 1 commit into from
Oct 30, 2021

Conversation

fmarmol
Copy link

@fmarmol fmarmol commented Jul 20, 2021

I suggest theses changes because I could see some improvements on my tests regarding the following benchmark:

import (
        "testing"

        "github.com/shirou/gopsutil/v3/net"
)

func BenchmarkConnections(b *testing.B) {
        for i := 0; i < b.N; i++ {
                net.Connections("all")
        }
}
✦ ➜ benchstat old.txt new.txt
name           old time/op    new time/op    delta
Connections-8    20.8ms ± 0%    16.7ms ± 0%   ~     (p=1.000 n=1+1)

name           old alloc/op   new alloc/op   delta
Connections-8    4.38MB ± 0%    4.01MB ± 0%   ~     (p=1.000 n=1+1)

name           old allocs/op  new allocs/op  delta
Connections-8     45.2k ± 0%     42.4k ± 0%   ~     (p=1.000 n=1+1)

Can you confirm that these improvements are relevants?

@Lomanic
Copy link
Collaborator

Lomanic commented Jul 20, 2021

@fmarmol
Copy link
Author

fmarmol commented Jul 20, 2021

@Lomanic Ok thx for the reply, I didn't pay attention about the version. I think we can close this PR.

@shirou
Copy link
Owner

shirou commented Jul 23, 2021

Thank you for your contribution!
Go 1.15 will be out of support when 1.17 is released. And perhaps 1.17 will be release within a few month, I want to leave this PR open.

Copy link
Owner

@shirou shirou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to late response. Time passed from 1.17 released, I think it's safe to merge now. Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants