Well there are a few things you should keep in mind:
First of all an imported model might have either a MeshRenderer + MeshFilter component or a SkinnedMeshRenderer. So you may want to check for both a SkinnedMeshRenderer and a MeshFilter in case no SkinnedMeshRenderer was found.
The second point is: do not use the mesh property inside the editor, ever. The mesh property will try to instantiate the mesh for this MeshFilter only. However this only works at runtime and is only ment for runtime use. Inside the editor you should always use the sharedMesh property.
inside editor code you should not use Instantiate unless you really know what that means. Instantiating an object means you create a clone in the current scene. Note that this clone is not connected to the prefab / source object it came from. For anything prefab related inside the editor you want to have a look at the PrefabUtility class and in particular the InstantiatePrefab method.
To count all the vertices of a prefab when it’s imported you may want to use: