1. An inspection method comprising: virtually dividing a sample, in which a plurality of chip patterns are formed, into a plurality of strip-shaped stripes along a predetermined direction to acquire an optical image of the chip pattern in each of the stripes; performing filtering based on design data of the chip pattern to produce a reference image corresponding to the optical image; comparing the chip pattern using a die-to-database method and comparing a repetitive pattern portion in the chip pattern using a cell method; obtaining at least one of a dimension difference and a dimension ratio between a pattern of the optical image and a pattern of the reference image compared to the pattern of the optical image by the die-to-database method; and obtaining a dimension distribution of the plurality of chip patterns from at least one of the dimension difference and the dimension ratio, wherein, with respect to a position determined to be a defect by the comparison of the die-to-database method, a result of the die-to-database method is stored when a dimension distribution from the position to a preceding position where at least one of the dimension difference and the dimension ratio is obtained falls within a predetermined range by comparing the dimension distribution to a dimension distribution in the stripe including the position determined to be the defect, or a dimension distribution of the chip pattern assumed from the stripe in which the dimension difference is acquired in advance of the stripe concerned, and a result of the cell method is stored instead of the result of the die-to-database method when the dimension distribution from the position determined to be the defect to the preceding position where at least one of the dimension difference and the dimension ratio is obtained exceeds the predetermined range by comparing the dimension distribution to the dimension distribution in the stripe including the position determined to be the defect, or the dimension distribution of the chip pattern assumed from the stripe in which the dimension difference is acquired in advance of the stripe concerned.