From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 5276A7EE56 for ; Fri, 7 Dec 2012 03:33:57 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of berenger@riken.jp) identity=pra; client-ip=134.160.33.161; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="berenger@riken.jp"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of berenger@riken.jp designates 134.160.33.161 as permitted sender) identity=mailfrom; client-ip=134.160.33.161; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="berenger@riken.jp"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of postmaster@postman.riken.jp designates 134.160.33.161 as permitted sender) identity=helo; client-ip=134.160.33.161; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="berenger@riken.jp"; x-sender="postmaster@postman.riken.jp"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvoBAAJVwVCGoCGhnGdsb2JhbABEvS8EBIEUDgEBAQEBCAsJCRQngkwRQD0WGAMCAQIBWAgBAYgMoT2hL41TgykDiF2NJoVrjV4 X-IronPort-AV: E=Sophos;i="4.84,234,1355094000"; d="scan'208";a="185018919" Received: from postman1.riken.jp (HELO postman.riken.jp) ([134.160.33.161]) by mail1-smtp-roc.national.inria.fr with ESMTP; 07 Dec 2012 03:33:55 +0100 Received: from postman.riken.jp (postman1.riken.jp [127.0.0.1]) by postman.riken.jp (Postfix) with SMTP id C291E32C030C for ; Fri, 7 Dec 2012 11:33:52 +0900 (JST) Received: from [172.27.98.103] (rikad98.riken.jp [134.160.214.98]) by postman.riken.jp (Postfix) with ESMTPA id 8823632A0047 for ; Fri, 7 Dec 2012 11:33:52 +0900 (JST) Message-ID: <50C15590.1010507@riken.jp> Date: Fri, 07 Dec 2012 11:33:52 +0900 From: Francois Berenger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version: 5.6.0.2009776, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.12.7.22415 Subject: [Caml-list] What is the fastest? Pattern matching or if then else Hello, I always wondered what is the fastest (at least for integers): match n with 0 -> (* do something *) | _ -> (* do something else *) or if n = 0 then (* do something *) else (* do something else *) Sometimes I have some code that would be more beautiful if I was using only pattern matching rather than pattern matching interspersed with if then else directives. Is one significantly faster than the other? Is it the same cost at runtime? Thanks a lot, F.