Message ID | 20240301201306.2680986-2-irogers@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-89062-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp130462dyc; Fri, 1 Mar 2024 12:13:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXKYY4nlxVtDu+qiNC+0rlkkaBG2yh2tBvU3dXG3pyFDCp5WP3Bl7U/sOyFWOdY2I+y64LLjsf/6T+kAEVhDBs3sdQmBA== X-Google-Smtp-Source: AGHT+IGRv/6CgBsZ0oK2YI+kpbeVfOLwLIgr0jLmF6klwvJKiyEN84MQsVPMjnuF2ysSYj2gJnsp X-Received: by 2002:a05:620a:1673:b0:788:188a:37de with SMTP id d19-20020a05620a167300b00788188a37demr93156qko.62.1709324031497; Fri, 01 Mar 2024 12:13:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709324031; cv=pass; d=google.com; s=arc-20160816; b=g4BCeli7fldevF4/VLcLU9/KKNIfYSNNIYrFOSSTG9MsDe+aLwHjFRr3qxMRdYNwSM qie1413JNRgSbJ0mOHxSQVkClFHc8J5SjsEjRNZEQe8wcGVG9fwkstUKb0RG+o8iuV0w 06FMXfqmFMCJyLOe+OTzlYlOFqDCKiFoZ1nDHEl+wKuR4VbV1VnFjVJdwvk17c493s75 rvoQHe6JiOSx70PPsPrEvv/v3VUMqrHwuvgd29EK0SjYGTLnJTLJHHoJMSi/O4Hyc+yg tTJyZ315iMNarSviRUmpG19ROQY6UwdtjOP5v3B0U9MTXeZRPRTMEHBgiQC2CeFOi008 pNpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=leHy2ZuaaIVqOoEaFIcU0dOPh3TtFIVXPy4dpXtCtQQ=; fh=OJHqQpgyNkKXIRyRuRdTK0WDEtuJxlqqyuFW6Jwmdic=; b=Z4yVkJ/ufNbpRy7efRuCNzyHAYDIIdVPt+u2tV3UkQbloT/vgDiOS33JuBiIm2x89b SV1GFSqFSZEfW8W+awDsrJhUULXleOJSqGVPxIZoqySkYzYDv4syOYM0TFNIqI40919s +INXR+atU13vtzfjyd8vJkwlzAFFcqfCVNr54ZxPdeYqRTDpk+SJwsCdUgws6VzCjtSo ZAslcZxg1Ci5utav3zLH51kzLUc/P8pOvQDEgVxhBiP2B1UKlUUT3aNANUayLTFe6Wip bFpY/QCE48f7euVayNo/znhTkHH/wft6vSQ+GB+DpchGaS6K8M3cCWFKMtsN3xoi/zqw 2WNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4uuUvcJP; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a16-20020a05620a02f000b00787dea877e0si4244405qko.188.2024.03.01.12.13.51 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 12:13:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4uuUvcJP; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89062-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89062-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 46A391C24134 for <ouuuleilei@gmail.com>; Fri, 1 Mar 2024 20:13:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0518D3D0A4; Fri, 1 Mar 2024 20:13:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4uuUvcJP" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA9DC3C470 for <linux-kernel@vger.kernel.org>; Fri, 1 Mar 2024 20:13:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709324003; cv=none; b=WOgB02p1OtWjW588rMP3aXBSDX9E1RXbFoQOI8hgmExgTeZySG+pjL11C0clL4LaKEdfcAw6Vkm5b/jaymtDv0QgRkT1tBjtJIWGNjS5zfPT5bseSw3iGuTs8+fvwj+YI8OPPwDvwBZjsLhF0CbPr3ZYbFjonhkhx4KFI6AWwVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709324003; c=relaxed/simple; bh=+kXeHXthEWZD7iWx2K1wgOR5WC1VJeE1+Ab0otEfR+s=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Q0Zwn4Q9Sxochww1gwpGJ9x2duabU2SvV32fh2HtmoYEtIFTbbWCct9kAm4FKjVnAWo4Whhu4ECscx4EdvBtK//tsgjvIBdbaoZAdYXnIOGwm7MhmUcf975qI1naNFoGCcbZDLMWQJ4rLhZJtnIkqxY2yXfLXdgNYS1ywT98kWE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4uuUvcJP; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b26783b4so3523051276.0 for <linux-kernel@vger.kernel.org>; Fri, 01 Mar 2024 12:13:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709324001; x=1709928801; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=leHy2ZuaaIVqOoEaFIcU0dOPh3TtFIVXPy4dpXtCtQQ=; b=4uuUvcJP4diR1DgxCzpfQ0oXzCEZRYp7YbVphmRn3/ubpFdYpJqYn1W031AhxHbpU9 HgFOCH1qHJDvMyrosnPmJKgZsrgZvAq6FPVcREKlLKFUJzb0a/iOVpskNZ8ZpK2xnFVd /bU6HPEQXgeyA0C6zMMP3mFlVqvmzhm5EgmTuXjPS977SvRKtiSu/fO2B+YXCJe/6WHM f7MNR+5LpRoGXjJgupuo+vIrzEukBZVmK/r2wTw4kd9KXr3jPlmkqUQNQEyifLrJ0ZG3 WL7LUzU3TnWNEl8qiYlkdn+qDSKz8dwtCtuerR/aIeul1vkW/Dfnbdgqvz2EBjU21sem F80Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709324001; x=1709928801; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=leHy2ZuaaIVqOoEaFIcU0dOPh3TtFIVXPy4dpXtCtQQ=; b=f054WW925USVO45b50Z+IHPb8WW3YsPV9jchDubQRUrgjCfN8RlYKa0vjEijX1Ptsc q9ckqRNCzRAwmtSx7ypFhaqyl2ETOvKPfabERKTImnhgAVVJjsFpWZ0NRdiayEa5cN+I rYGz+ce52ySnzFdKqOo3XNouOXGmzdJF2Ud207jyanTh9zDVLzGwtihapYVwRyc1kRoC gtCX3XRr22tDDXk5QaqJCyDxCEE6A7whe0mJ2IWLhX8LIFBediM0JSmEotpZRLM4F2Wg XzrEw5MgshftidqZ3FDRHZ1USJXdCZs6/nqFdLT2m+zO0JFgBq8WyHmMSuqgpVo6oiJp 3YXg== X-Forwarded-Encrypted: i=1; AJvYcCXx5HNrCzJ7c4m6LpXMADhF80+OSoV1kJJpKFCXAlWMgZXCmEveEZKFGc9S5VdrEGP6GneXqPEUWWlsvktir7Rp5AfY1p5GGrSqwLlv X-Gm-Message-State: AOJu0Yx3quOV+NrjgVECxtVCxxdovddW1nYR8fYWL5q3bf2DoUjSjGqI wh8TcSNToBo4IzLJJ7pDteUrlxQUklrpERzrSV39MKAnA1bJGGd9bq4frRnR/0qQHoIvuarrkLu 8y9P59Q== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a25:ce8a:0:b0:dcc:8927:7496 with SMTP id x132-20020a25ce8a000000b00dcc89277496mr102198ybe.5.1709324000837; Fri, 01 Mar 2024 12:13:20 -0800 (PST) Date: Fri, 1 Mar 2024 12:13:06 -0800 In-Reply-To: <20240301201306.2680986-1-irogers@google.com> Message-Id: <20240301201306.2680986-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 References: <20240301201306.2680986-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 2/2] perf help: Lower levenshtein penality for deleting character From: Ian Rogers <irogers@google.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792356155446967330 X-GMAIL-MSGID: 1792356155446967330 |
Series |
[v2,1/2] perf: Suggest inbuilt commands for unknown command
|
|
Commit Message
Ian Rogers
March 1, 2024, 8:13 p.m. UTC
The levenshtein penalty for deleting a character was far higher than
subsituting or inserting a character. Lower the penalty to match that
of inserting a character.
Before:
```
$ perf recccord
perf: 'recccord' is not a perf-command. See 'perf --help'.
```
After:
```
$ perf recccord
perf: 'recccord' is not a perf-command. See 'perf --help'.
Did you mean this?
record
```
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/help-unknown-cmd.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c index 2ba3369f1620..a0a46e34f8d1 100644 --- a/tools/perf/util/help-unknown-cmd.c +++ b/tools/perf/util/help-unknown-cmd.c @@ -73,10 +73,14 @@ const char *help_unknown_cmd(const char *cmd, struct cmdnames *main_cmds) if (main_cmds->cnt) { /* This reuses cmdname->len for similarity index */ - for (i = 0; i < main_cmds->cnt; ++i) + for (i = 0; i < main_cmds->cnt; ++i) { main_cmds->names[i]->len = - levenshtein(cmd, main_cmds->names[i]->name, 0, 2, 1, 4); - + levenshtein(cmd, main_cmds->names[i]->name, + /*swap_penalty=*/0, + /*substition_penality=*/2, + /*insertion_penality=*/1, + /*deletion_penalty=*/1); + } qsort(main_cmds->names, main_cmds->cnt, sizeof(*main_cmds->names), levenshtein_compare);