It takes a long time to build(4-5mins) in Mbed Studio. Is there any way to build faster like it happens in online compiler???
The online compiler uses a massive server with multi-threaded processes to compile your build as fast as possible. It also uses some pre-caching tricks for Mbed OS. The offline Mbed Studio relies on your local machine to build (though every build after the first one should be faster as the initial compilation is done). So in short no, it is not possible as your local machine’s CPU is the bottle neck. This may be a good excuse to upgrade your PC though!
One thing to keep in mind, if you change mbed_app.json it will trigger a clean re-compile (and take a while to build), so if possible move things you change frequently into main.cpp.