{"id":28283,"student_id":10,"content":"var vendor1 = createSprite('vendor_1.png');\nvendor1.scale = 0.2;\nvar vendor2 = createSprite('vendor_2.png');\nvendor2.scale = 0.2;\nvendor2.y -= 100;\nvar vendor3 = createSprite('vendor_3.png');\nvendor3.scale = 0.2;\nvendor3.y += 100;\n\nvar schedule1 = [];\nvar schedule2 = [];\nvar schedule3 = [];\n\nschedule1.time = 0;\nschedule1.done = 0;\nschedule2.time = 0;\nschedule2.done = 0;\nschedule3.time = 0;\nschedule3.done = 0;\n\nforever(function(){\n if (Math.random()*60 \u003c 1 \u0026\u0026 ( schedule1.length + schedule2.length + schedule3.length) \u003c 60) {\n var task = Math.floor(Math.random()*150);\n schedule1.push(task);\n schedule2.push(task);\n schedule3.push(task);\n }\n \n schedule1.time += schedule1.length;\n schedule2.time += schedule2.length;\n schedule3.time += schedule3.length;\n print(schedule1, 10, 10, 'black');\n print(schedule2, 10, 30, 'black');\n print(schedule3, 10, 50, 'black');\n print('平均等待時間:' + Math.floor(schedule1.time/schedule1.done) + 'ms', 50, 140, 'black', 20);\n print('平均等待時間:' + Math.floor(schedule2.time/schedule2.done) + 'ms', 50, 240, 'black', 20);\n print('平均等待時間:' + Math.floor(schedule3.time/schedule3.done) + 'ms', 50, 340, 'black', 20);\n});\n\n// Shortest Job Firs\nforever(function () {\n if (schedule1.length \u003e 0)\n schedule1[0] -= 1;\n \n if (schedule1[0] \u003c= 0) {\n schedule1.shift();\n schedule1.done++;\n schedule1.sort(function (a, b) {\n return a - b; \n });\n }\n});\n\n// First-Come First-Served\nforever(function () {\n if (schedule2.length \u003e 0)\n schedule2[0] -= 1;\n \n if (schedule2[0] \u003c= 0) {\n schedule2.shift();\n schedule2.done++;\n }\n});\n\n// Round Robin\nvar count = 0;\nforever(function () {\n if (schedule3.length \u003e 0 \u0026\u0026 schedule3[count])\n schedule3[count] -= 1;\n \n if (schedule3[count] \u003c= 0) {\n schedule3.splice(count, 1);\n schedule3.done++;\n count--;\n }\n \n if (schedule3[count + 1]) count++;\n else count = 0;\n});\n\n","created_at":"2018-05-08T17:13:32.328+08:00","updated_at":"2019-11-11T04:09:09.467+08:00","name":"Schedule 排程","language":"javascript","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/28283/7beb1895257e12668c7bf721f45f69a5.jpg"},"parent_id":2,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":318,"hashid":"2pdsy9rn","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":521386,"file_name":"vendor_1.png","project_id":28283,"asset_id":63753,"created_at":"2018-05-08T18:16:47.384+08:00","updated_at":"2018-05-08T18:16:47.384+08:00"},{"id":521387,"file_name":"vendor_2.png","project_id":28283,"asset_id":63754,"created_at":"2018-05-08T18:16:47.385+08:00","updated_at":"2018-05-08T18:16:47.385+08:00"},{"id":521388,"file_name":"vendor_3.png","project_id":28283,"asset_id":63755,"created_at":"2018-05-08T18:16:48.829+08:00","updated_at":"2018-05-08T18:16:48.829+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦