I wouldn't worry about speed -- this is a batch process, and it'd be hard to make anything like that take more than a second or two, no matter how inefficiently you wrote it!