macOS 11: Get system information (GPU, resolution) programmatically (in C) [closed]

I need to access data about GPU and screen resolution in C, not using system_profiler, because it takes too long(.3s-.5s system_profiler SPDisplaysDataType), and needs greping and cutting, which is not that fast either.

Caching would be answer, but very short-sighted as someone can use different monitors etc.

Unfortunately system_profiler is closed source.

EDIT: I used CGDisplayPixelsWide and CGDisplayPixelsHigh to get resolution. During compilation i had to compile with -framework Cocoa -framework IOKit. Only minus that it gets system resolution rather than screen resolution. So function looks like this.

static char *get_resolution()
{
        int screen_width = CGDisplayPixelsWide(CGMainDisplayID());
        int screen_height = CGDisplayPixelsHigh(CGMainDisplayID());
        ...
}

Solution 1:

displayplacer allows to read and write display settings and is open source. I'm not sure about GPU details though.

The API used seems to be defined in IOKit/graphics/IOGraphicsLib.h.