Conditional access_log

How can I disable log to access_log based on a runtime condition?
Example that does not works:

    if ($http_user_agent ~* httperf) {
      access_log off;
    }

thanks in advance.