TAILIEUCHUNG - Programming java 2 micro edition for symbian os phần 9

XML là thuận tiện, nó là dễ dàng để xác nhận tính hợp lệ và có nhiều công cụ hiện có và các API để đơn giản hóa việc sử dụng nó, cho phép các mẫu thử nghiệm chi phí ứng dụng sẽ được tạo ra trong thời gian tối thiểu. | 3 72 WRITING OPTIMIZED CODE Optimizing the LifeEngine Class LifeEngine contains the algorithm that creates the new generation from the old generation. Rather than go through the code line by line it is probably less painful to give a description. The initial implementation used two GenerationMaps one to hold the new generation thisGeneration and one to hold the old generation lastGeneration . looking at the Game of Life rules we have to examine each live cell if it has two or three neighbors it lives so we create a new cell in thisGeneration at the old cell location we also have to examine empty cells that have three neighbors. The way the program does this is to examine every cell adjacent to every live cell if it is empty and has three live neighbors we create a new cell in thisGeneration at the empty location having calculated and displayed the new generation the new generation becomes the old generation and the new generation map is cleared run loops once per generation it goes through all the cells in lastGeneration and calls createNewCell to check whether the cell should live or die and to check if the eight neighboring cells should live or die this translates to a lot of calls to isAlive One significant optimization was applied. testedCells is a GenerationMap used to hold the tested cells. So whenever a cell is checked whether it is empty or not a cell with the same position is created in testedCells. So before testing if a cell should live or die cre-ateNewCell first checks in testedCells to see if it has already been tested if so it does not test it again. This optimization improved the speed of LifeTime by over 30 57s down to 34s . However the extra memory required is significant if there are 200 live cells in a generation there will be some 800 tested cells. At 23 bytes per cell that is about 18 KB. Tools for Optimization a Diversion Taking a guess and test approach to improving performance or reducing memory requirements can work but is .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.