From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Cross Subject: Re: How to set time limit and memory limit for execution of source blocks Date: Tue, 04 Feb 2020 18:23:21 +1100 Message-ID: <87sgjq6ck6.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:51705) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iysYT-0004bL-Qv for emacs-orgmode@gnu.org; Tue, 04 Feb 2020 02:23:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iysYS-00052m-JJ for emacs-orgmode@gnu.org; Tue, 04 Feb 2020 02:23:29 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:34988) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iysYS-0004wf-8W for emacs-orgmode@gnu.org; Tue, 04 Feb 2020 02:23:28 -0500 Received: by mail-pf1-x42a.google.com with SMTP id y73so9004069pfg.2 for ; Mon, 03 Feb 2020 23:23:28 -0800 (PST) Received: from tim-desktop (203-173-17-111.dyn.iinet.net.au. [203.173.17.111]) by smtp.gmail.com with ESMTPSA id iq22sm1968679pjb.9.2020.02.03.23.23.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 23:23:26 -0800 (PST) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org This is probably something which would need to be addressed in the interpreter/compiler of the language you are using rather than within Emacs or org-mode. I would suspect that in your case, you are best off tangling the source blocks to create separate executable scripts/code which you then run outside of Emacs itself. Running the code blocks from within org-mode/Emacs is going to adversely impact on the execution time (it will be slower) and complicates/muddies calculation of memory usage (you really only want to count the memory used by the child process running your code, not that of Emacs). Using tangled source code files will also allow you to use OS tools for timing and memory metrics (depending on what platform your on). If your source code blocks are emacs-lisp, things are a little different. There will still be some overhead which may impact on performance. I don't think you can easily identify memory useage (i.e. memory used by your source code as opposed to memory used by Emacs for everything else). Anoop GR writes: > Dear Emacs hackers, > > Like all of you, I think orgmode is the best way to organise study notes. > > I am solving competitive programming questions from Topcoder.com > There are strict guidelines on memory limit of 256MB and time limit of 2sec > for solutions > > How do I enforce the same on my orgmode source blocks. > I want the execution to stop whenever it exceeds the above limits on memory > and time. > > Long live Emacs, > Anoop -- Tim Cross