去评论
dz插件网

Web前端性能测试平台开发(Flask)

迪巴拉
2024/08/16 12:01:51





銆銆寮绡囧厛鎵撲釜灏忓箍鍛婏紝鍦ㄣ婂皬璇曠墰鍒鈥斿畬鏁村疄渚嬪甫浣犳帰绌禠R鎬ц兘娴嬭瘯銆嬮偅绡囧皬鏂囦腑鎴戞湁璇村埌鎬ц兘娴嬭瘯瑕佸仛鍒版ц兘鐨勫師瀛愬寲锛岃繖鏍锋垜浠妸鎬ц兘鍙互鍒嗕负鍓嶇锛岀綉缁滐紝涓棿浠讹紝APP(搴旂敤)锛屾搷浣滅郴缁燂紝鏁版嵁搴撶瓑锛屼粖澶╋紝鎴戜滑鏉ヤ竴璧峰紑鍙戜竴涓笓闂ㄥWeb鍓嶇鎬ц兘鑷姩鍖栧钩鍙(鍚庣画鍙互鍦ㄨ鐗堟湰鐨勬妧鏈拰鍩虹涓婂畬鍠勫叾浠栧姛鑳斤紝姣斿璇达細鎺ュ彛鐨勮嚜鍔ㄥ寲鍜屾帴鍙fц兘浠ュ強瀵瑰叾浠栧眰鐨勭洃鎺ф暟鎹仛鍙鍖)銆

銆銆涓锛氳鍟ヨ嚜琛岃溅锛熷ア渚堬紒

銆銆澶у閮芥噦鏁蹭唬鐮佷箣鍓嶆湁寰堝浜嬫儏瑕佸仛骞朵笖鏄渶閲嶈鐨勪簨鎯(鑳芥暡浠g爜鐨勪汉澶氱殑鏄紝鏈閲嶈鐨勬槸鑳戒骇鍑哄彂鐜伴棶棰樺苟缁欏嚭瑙e喅绛栫暐鐨刬dea )锛寃hat's this? 褰撶劧鏄渶姹傚垎鏋愩

銆銆鎴戜滑鐨勬効鏅細

銆銆瀹炵幇Web鍓嶇鎬ц兘娴嬭瘯(鑷姩閬嶅巻鎵鏈夐〉闈) 鐩戞帶姣忎釜椤甸潰鍔犺浇鏃堕棿娈电殑鑰楁椂锛屽苟涓旂粺璁℃瘡涓〉闈腑闄勫姞鐨勮祫婧(css/js/img/XmlHttpRequest)鏈鍚庡埄鐢ㄧ簿缇庣殑鍥捐〃浣滃睍鐜般

銆銆鎶鏈彲琛屾у垎鏋愶細

銆銆鑷姩閬嶅巻鎵鏈夐〉闈紵娌¢棶棰樺晩 webdriver鏄繖鍧楀効鐨勫埄鍣ㄥ晩銆

銆銆濡備綍缁熻椤甸潰鍔犺浇鏃堕棿鍛紵performance.timing缁濆闈犺氨銆

銆銆鍝効鏈夌簿缇庣殑鍥捐〃锛熺櫨搴charts鍥㈤槦涓轰綘鍒嗗咖瑙i毦銆

銆銆鎶鏈夊瀷锛

銆銆杩欐槸涓潪甯稿煎緱鎺㈣鐨勯棶棰橈紝鏈変簺Leader鏄患鍚堝洟闃熺幇鐘跺拰瀹炴柦鎴愭湰(鏂版妧鏈槸闇瑕佽姳鏃堕棿瀛﹀晩)锛涙湁浜涚煡涔庡厷灏变笉璇翠簡锛屽暐鏈鏂扮敤鍟ワ紝鍙敤鏈鏂扮殑锛屼笉鐢ㄦ渶鍚堥傜殑锛涘綋鐒惰繕鏈変竴浜涗汉瀹屽叏鏄潬鑷繁鐨勫叴瓒f媿鑴戣鍐冲畾鐨勩

銆銆鎴戜滑杩欓噷閫夋嫨python+webdriver+flask+sqlite+bootstrap+jquery鏉ュ畬鎴愭垜浠繖涓皬骞冲彴鐨勫紑鍙戯紝鑷充簬涓轰粈涔堜細閫夋嫨杩欏嚑绉嶆妧鏈紝瀛︿範鎴愭湰浣庯紝寮鍙戞晥鐜囬珮锛屾昏岃█涔嬩竴鍙ヨ瘽ROI楂橈紒

銆銆濂藉槥~ 绔ラ瀷浠彲浠ュ厛鑴戣ˉ涓嬭嚜宸辨兂瑕佷粈涔堟牱鐨勪氦浜掗〉闈紝鎴戣繖閲岀粰鍑轰竴涓渶绠鍗曠殑鍢垮樋~

銆銆涓婚〉闈細(灞曠ず缁熻鍒扮殑椤甸潰淇℃伅骞朵互鍫嗗彔鍥炬柟寮忓睍绀烘ц兘鏁版嵁)锛



銆銆椤甸潰璇︽儏椤甸潰锛(灞曠ず椤甸潰涓檮鍔犺祫婧愮殑缁勬垚浠ュ強璇ラ〉闈㈠巻鍙茬増鏈殑鏁版嵁瀵规瘮鍥)







銆銆锛坧s锛氬鎶鏈夊瀷杩欏潡鍎垮悓瀛︿滑鍙互鏍规嵁鑷繁鐨勯渶瑕佸仛鏀瑰彉

銆銆濡傛灉浣犱笉鎯崇敤flask 鍙互鎹㈡垚Django妗嗘灦

銆銆濡傛灉浣犱笉鎯崇敤sqlite鏁版嵁搴 鍙互鎹㈡垚mysql鎴栬呭叾浠栫殑NoSql绫绘暟鎹簱

銆銆濡傛灉浣犱笉鎯崇敤jquery 閭d綘鐨勯夋嫨灏辨洿澶氫簡 浠涔圧eact,Nodejs,Vuejs,Angularjs杩樻湁鍟ackbone.js鐪艰姳缂贡銆

銆銆鎴戜釜浜哄枩濂藉皬鑰岀簿鑷寸殑涓滆タ 灏辨嬁flask鏉ヨ鍚 瀹冩槸涓井鍨嬫鏋惰繙杩滄病鏈塂jango閲嶏紝浣嗘槸flask涓板瘜鐨勬彃浠跺彲浠ヤ緵鎴戜滑蹇熷湴瀹屾垚浠诲姟銆傛墍浠ュ槢锛岃鍟jango瑕佸暐鑷杞︼紝鍒お濂緢銆

銆銆鎶鏈病鏈塋ow涓峀ow涔嬪垎锛 鍙湁閫傚悎涓嶉傚悎銆傦級

銆銆浜岋細杩欎釜杞鏄笓闂ㄤ负浣犺璁$殑

銆銆杩欓噷鏄搴旇蒋浠跺伐绋嬮噷鐨勬瑕佽璁¢樁娈点傜粡杩囧墠闈㈢殑姊崇悊锛屾垜浠緢娓呮鍦扮煡閬撹嚜宸辨兂瑕佺殑鏄粈涔堜簡銆傚棷~鎺ヤ笅鏉ュ挶鎶婄‖閭﹂偊鐨勯渶瑕佽浆鍖栦负杞欢宸ョ▼閲岀殑涓滀笢鍚с

銆銆鏁版嵁搴擄細鎴戜滑寤轰袱寮犺〃鍒嗗埆瀛樻斁鎵鏈夐〉闈㈢殑缁熻鏁版嵁灏卞彨WebPages锛岃繕闇瑕佸缓绔嬩竴寮犺〃鏉ュ瓨鏀炬瘡涓〉闈㈢殑璇︾粏淇℃伅 鎴戜滑鍙玃ageDetail銆

銆銆寤鸿〃璇彞濡備笅锛

銆銆CREATE TABLE [PageDetail] (

銆銆[project] text,

銆銆[resourceName] text,

銆銆[requestType] text,

銆銆[pageRequestCount] INTERGER,

銆銆[resourcetSize] INTERGER,

銆銆[resourceLoadTime] INTERGER,

銆銆[createTime] datetime,

銆銆[pageName] text,

銆銆[pageLoadTime] INTEGER);

銆銆CREATE TABLE WebPages (project text, name text ,url text  ,direct INTERGER ,domReady INTERGER, loadEvent INTERGER ,request INTERGER ,ttfb INTERGER,loadPageAll  INTERGER ,ifredirect INTERGER, createTime  datetime);

銆銆鎺ュ彛锛

銆銆鎴戜滑閲嶆柊鎵ц鑴氭湰鏉ョ粺璁″墠绔ц兘鐨勮瘽锛岄渶瑕佽皟鐢ㄦ帴鍙c

銆銆鎴戜滑灏卞懡鍚嶄竴涓帴鍙e惂锛宲ython-flask閲屾帴鍙g殑瀹氫箟寰堢畝鍗曞摝~

銆銆# 閲嶆柊鎵ц娴嬭瘯鑴氭湰

銆銆@app.route('/redo', methods=['GET', 'POST'])

銆銆def redo():

銆銆if request.method == 'GET':

銆銆return u'璇ユ帴鍙d笉鏀寔GET鏂规硶璁块棶'

銆銆else:

銆銆# 鍚戞祴璇曠幆澧冨彂鐢焔et璇锋眰鏉ラ獙璇佹祴璇曠幆澧冩槸鍚﹀瓨鍦

銆銆if env_test_code == 200:

銆銆# 閲嶆柊鎵ц娴嬭瘯鑴氭湰

銆銆Else锛

銆銆Return 娴嬭瘯鐜涓嶅瓨鍦

銆銆濡傛灉鎴戜滑閫夋嫨涓嶅悓鐗堟湰鐨勮瘽锛屾垜浠篃闇瑕佽皟鐢ㄦ帴鍙f潵杩斿洖鎵閫夌増鏈殑娴嬭瘯鏁版嵁锛

銆銆@app.route('/index', methods=['GET', 'POST'])

銆銆def index():

銆銆if request.method == 'POST':

銆銆# 浠巃jax璇锋眰涓彇鍙傛暟selected_version 鍙栦笉鍒板垯涓簄ull

銆銆version_text = request.form.get("selected_version", "null")

銆銆else:

銆銆version_text = '榛樿鐗堟湰鍙'

銆銆# 鎺ヤ笅鏉ュ反鎷夊反鎷変粠sqlite涓彇鏁版嵁骞惰繑鍥

... ...

鍑鸿嚜銆51娴嬭瘯澶╁湴銆嬪師鍒涙祴璇曟枃绔犵郴鍒楋紙鍥涘崄浜旓級



 鎺ㄨ崘闃呰
鐐瑰嚮闃呰鈽濿eb绔祴璇曞拰绉诲姩绔祴璇曠殑鍖哄埆

鐐瑰嚮闃呰鈽濿eb鍓嶇鎬ц兘娴嬭瘯鍙婁紭鍖栨妧宸

鐐瑰嚮闃呰鈽炵Щ鍔ㄥ簲鐢ㄦ祴璇曚笌Web搴旂敤娴嬭瘯涔嬩笉鍚

鐐瑰嚮闃呰鈽濿eb鑷姩鍖栨祴璇曟鏋惰璁

鐐瑰嚮闃呰鈽濿eb娴嬭瘯涓殑A/B娴嬭瘯浠庡叆闂ㄥ埌鐔熺粌鎸囧崡





鐐瑰嚮宸︿笅瑙掆滈槄璇诲師鏂団濇煡鐪嬪叏鏂囧唴瀹癸紒