Adding to Philippe Tailhades answer, If the density of the bulk material is known, you can calculate the porosity from the density of the thin film. To measure the density of the thin film you can deposit the film on a quartz microbalance and measure its thickness with another technique such as AFM or profilometry. Depending on the size of the pores you could also use an optical technique, the best option would be ellipsometry, if the material index of refraction and thickness are known, it is relatively simple to find the porosity, if they are not known, it is still possible but requires an experienced user. A transmition technique could also work if bulk extinction coefficient and thickness are known.
In my opinion, the two compactness instrumentations for calculating thin film compactness are ellipsometry, which measures film thickness and refractive index, both of which are important parameters for compactness calculations and X-ray reflectometry(XRR), which measures film thickness, surface roughness, and compactness .