! @brief Quickly analyze flash contents and compute weights for sector erase.

        Quickly estimate how many pages are the same.  These estimates are used
        by _sector_erase_program so it is recommended to call this before beginning programming
        This is done automatically by smart_program.

def _compute_sector_erase_pages_and_weight(self, fast_verify):
        """! @brief Quickly analyze flash contents and compute weights for sector erase.

        Quickly estimate how many pages are the same.  These estimates are used
        by _sector_erase_program so it is recommended to call this before beginning programming
        This is done automatically by smart_program.
        """
        analyze_start = time()
        
        # Analyze pages using either CRC32 analyzer or partial reads.
        if self.flash.get_flash_info().crc_supported:
            self._analyze_pages_with_crc32(fast_verify)
            self.perf.analyze_type = FlashBuilder.FLASH_ANALYSIS_CRC32
        elif self.flash.region.is_readable:
            self._analyze_pages_with_partial_read()
            self.perf.analyze_type = FlashBuilder.FLASH_ANALYSIS_PARTIAL_PAGE_READ
        else:
            # The CRC analyzer isn't supported and flash isn't directly readable, so
            # just mark all pages as needing programming. This will also prevent
            # _scan_pages_for_same() from trying to read flash.
            self._mark_all_pages_for_programming()

        # Put together page and time estimate.
        sector_erase_count = 0
        sector_erase_weight = 0
        for sector in self.sector_list:
            for page in sector.page_list:
                if page.same is False:
                    sector_erase_count += 1
                    sector_erase_weight += page.get_program_weight()
                elif page.same is None:
                    # Page may be the same but must be read to confirm
                    sector_erase_weight += page.get_verify_weight()
                elif page.same is True:
                    # Page is confirmed to be the same so no programming weight
                    pass
            
            if sector.are_any_pages_not_same():
                sector_erase_weight += sector.erase_weight

        self.sector_erase_count = sector_erase_count
        self.sector_erase_weight = sector_erase_weight

        analyze_finish = time()
        self.perf.analyze_time = analyze_finish - analyze_start
        LOG.debug("Analyze time: %f" % (analyze_finish - analyze_start))
        
        return sector_erase_count, sector_erase_weight