1. 程式人生 > 實用技巧 >Flutter cached_network_image圖片快取異常/載入失敗優化

Flutter cached_network_image圖片快取異常/載入失敗優化

作業要求參見 https://edu.cnblogs.com/campus/nenu/2020Fall/homework/11207

作業0

#include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

int main(int argc, char* argv[])
{
    int loop_count = atoi(argv[1]);   //int atoi(const char *nptr);注意將字串轉換成int 
    srand((unsigned)time(NULL));
    
for(int i=0; i<loop_count;i++) { cout << rand() << "\n"; } cout << endl; return 0; }

  read.md

   #whitelist白名單

 1.安裝vs;
2.配置環境變數;
3.編譯create.cpp檔案;
4.執行“create 10 >whitelist”生成檔案whitelist;
5.執行“create 100 >q”生成檔案q;
6.編譯brute.cpp檔案;
7.執行“brute -w q < whitelist > output”

作業1

對上面兩段老楊寫的程式碼任選其一進行profile,觀察現象(要求有截圖記錄)。


在visual studio中使用快捷鍵ALT+F2開啟效能探查器,選擇【CPU使用率】



作業2

效能分析出錯,導致作業3作業4未能按時完成。但是肉眼也可以看出來ismatch()函式效率太低。

作業5

你覺得老楊的文件(readme),註釋和程式碼風格又哪些問題,該如何改進?

程式碼邏輯出錯:

(1)改正前的程式碼:

bool is_match(int t, int w[], int w_length)
{
    for(int i=0;i<w_length;i++)
    {
        
if(t!=w[i]) { return true; } } return false; }

改正後的程式碼:

bool is_match(int t, int w[], int w_length)
{
    for(int i=0;i<w_length;i++)
    {
        if(t==w[i])
        {
            return false;
        }
    }
    return true;
}

(2)註釋:

沒有功能介紹的註釋。

有無關注釋,程式碼檔案不整潔。

(3)踏踏實實打牢基礎。