AI编程工具Copilot与Codeium的实测对比

csdn原创谢绝转载

简介

现在没有AI编程工具,效率会打一个折扣,如果还没有,赶紧装起来.

  1. GitHub Copilot是OpenAi与github等共同开发的的AI辅助编程工具,基于ChatGPT驱动,功能强大,这个没人怀疑,看它的价格就知道了,最开始是10美元1个月,后面好像涨到20美元了.
    我个人给它起了个嘴强王者的称号,就是动动嘴就能实现代码.

  2. Codeium是一款免费的Ai辅助编程工具,支持70多种编程语言,插件支持40多种编辑器.功能也挺强大的,关键免费的,
    我称赞它为白Piao党们的编程秘书.
    其他文章
    AndroidStudio上安装Codeium方法.
    Android Studio安装AI编程助手Github Copilot

环境

  1. 测试使用的是Android Studio, Codeium要在VsCode上支持对话,这里只简单对比编程的功能.
  2. 语言Java

代码对比

在同一个Android Studio上,书写相似的简单代码,得到补全代码.然后对比二者表现.
代码尽量挑选平常会用到的公共函数.

Copilot

// 作者:帅得不敢出门
public class Copilot {// 用递归实现斐波那契数列public static int fibonacci(int n) {if (n <= 1) return n;return fibonacci(n - 1) + fibonacci(n - 2);}public void writeFile(String file, String content) {try {FileWriter fw = new FileWriter(file);fw.write(content);fw.close();} catch (IOException e) {e.printStackTrace();}}// 手动输入参数int dp后实现public int dp2px(int dp) {return (int) (dp * 3.0f + 0.5f);}// 手动输入Context参数public int dpToPx(Context context, int dp) {return (int) (dp * context.getResources().getDisplayMetrics().density + 0.5f);}// 实现获取最前端的Activity名称的函数// 输入上面这行,copilot无任何提示public String getTopActivity(Context context) {return context.getClass().getSimpleName();}public boolean isAppForeground(Context context, String packageName) {return packageName.equals(getTopActivity(context));}public boolean isAppSystem(Context context, String packageName) {return context.getPackageManager().getLaunchIntentForPackage(packageName) == null;}public int getStatusBarHeight(Context context) {int result = 0;int resourceId = context.getResources().getIdentifier("status_bar_height","dimen", "android");if (resourceId > 0) result = context.getResources().getDimensionPixelSize(resourceId);return result;}public int getScreenWidth(Context context) {return context.getResources().getDisplayMetrics().widthPixels;}public String bytes2HexString(byte[] bytes) {StringBuilder sb = new StringBuilder();for (byte aByte : bytes) {String hex = Integer.toHexString(aByte & 0xFF);if (hex.length() < 2) sb.append(0);sb.append(hex);}return sb.toString();}public boolean isPhoneNumber(String phoneNumber) {return phoneNumber.matches("^1[3-9]\\d{9}$");}public String getDate() {return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(new Date());}public String getCurrentTime() {return new SimpleDateFormat("HH:mm:ss", Locale.getDefault()).format(new Date());}public static int getTodayOfWeek() {return new Date().getDay();}public static int getDayOfWeek(Date date) {return date.getDay();}public static boolean isChinese(String str) {return str.matches("[\\u4e00-\\u9fa5]+");}/*这个会编译不过public boolean isScreenOn(Context context) {return context.getSystemService(Context.POWER_SERVICE).isScreenOn();}*/public void setBrightness(Context context, int brightness) {android.provider.Settings.System.putInt(context.getContentResolver(),android.provider.Settings.System.SCREEN_BRIGHTNESS, brightness);}public String getAndroidId(Context context) {return android.provider.Settings.Secure.getString(context.getContentResolver(),android.provider.Settings.Secure.ANDROID_ID);}}

Codeium

// 作者:帅得不敢出门
public class Codeium {// 用递归实现斐波那契数列public int fib(int n) {if (n == 0) {return 0;} else if (n == 1) {return 1;} else {return fib(n - 1) + fib(n - 2);}}// 输入到writeFile(会自动提示出参数及实现public void writeFile(String fileName, String content) {try {File file = new File(fileName);FileWriter fw = new FileWriter(file);fw.write(content);fw.close();} catch (IOException e) {e.printStackTrace();}}public int dp2px(int dp) {return (int) (dp * 0.5f + 0.5f);}// 要手动输入Context参数public int dpToPx(Context context, int dp) {return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics());}public String getTopActivity(Context context) {return "com.benew.testm";}public boolean isAppForeground(Context context, String packageName) {return false;}public boolean isAppSystem(Context context, String packageName) {return packageName.equals("com.android.systemui");}public int getStatusBarHeight(Context context) {return 0;}// 这个要手动输入Context参数public int getScreenWidth(Context context) {return context.getResources().getDisplayMetrics().widthPixels;}public String bytes2HexString(byte[] bytes) {StringBuilder sb = new StringBuilder();for (int i = 0; i < bytes.length; i++) {String hex = Integer.toHexString(0xFF & bytes[i]);if (hex.length() == 1) {sb.append('0');}sb.append(hex.toUpperCase());}return sb.toString();}public boolean isPhoneNumber(String phoneNumber) {// 默认是提示return false//return false;// 要手动先输入phoneNumber.matches(return phoneNumber.matches("^[1][3,4,5,7,8][0-9]{9}$");}public String getDate() {return new java.text.SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date());}public String getCurrentTime(){return new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date());}public static int getTodayOfWeek(){Calendar cal = Calendar.getInstance();return cal.get(Calendar.DAY_OF_WEEK);}public static int getDayOfWeek(Date date){Calendar cal = Calendar.getInstance();cal.setTime(date);return cal.get(Calendar.DAY_OF_WEEK);}public static boolean isChinese(String str){return str.matches("[\\u4E00-\\u9FA5]+");}public boolean isScreenOn(Context context){return false;}public void setBrightness(Context context, int level){// 这里如果不主动输入codeium会无提示, 需要手动输入android.providerandroid.provider.Settings.System.putInt(context.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS, level);}public String getAndroidId(Context context){// 这里codeium要手动输入return android.provider 才会提示, 否则会提示成return nullreturn android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);}}

结果

代码部分对比图
在这里插入图片描述

由于工具,语言,代码量都较单一,无法以偏盖全,只是做个简单比较,另外就是输入的代码也会干扰到补全,
个人输入的与工具本身理解不一样也会导致结果差异.

  1. 斐波那契数列 Copilot会更简洁些,二者都未有异常处理,比如溢出,输入负数.
  2. public void writeFile(String file, String content)差不多,Copilot少一行.
  3. public int dp2px(int dp)结果不同,一个是剩0.5,一个是0.3都有问题, 需要参数中手动输入Context context参数才行.
  4. public int dpToPx(Context context, int dp) 因为手动输入Context参数结果正确,个人更喜欢Codeium不需要关注运算.
  5. public String getTopActivity(Context context)二者都不正确.
  6. public boolean isAppForeground(Context context, String packageName) 二者都不正确.
  7. public boolean isAppSystem(Context context, String packageName)二者都不正确.
  8. public int getStatusBarHeight(Context context)Copilot表现比较好.
  9. public int getScreenWidth(Context context)结果一样.
  10. public String bytes2HexString(byte[] bytes)差不多.
  11. 获取时间的字符串的函数,format的格式需要自己微调.
  12. public boolean isPhoneNumber(String phoneNumber),Codeium需要手动输入部分实现,Copilot表现好.
  13. getTodayOfWeek() Copilot用到过期的函数,Codeium表现好些.
  14. public static boolean isChinese(String str)二都结果一样.
  15. 设备屏幕亮度setBrightness,获取AndroidId getAndroidId, Codeium都需要手动输入部分实现,否则补全不了,Copilot表现好.

单纯从以上对比,Copilot综合实力更强,收费的,开通麻烦点,原因你懂的.
Codeium也能解决大部分场景,它是免费的,免费的,免费的,重要的事情说三遍,开通方便.
最后说一下,土豪上Copilot,其他上Codeium.
作者:帅得不敢出门 CSDN原创谢绝转载

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/54809.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

数学建模—分类模型

本讲将介绍分类模型。对于而分类模型&#xff0c;我们将介绍逻辑回归&#xff08;logistic regression&#xff09;和Fisher线性判别分析两种分类算法&#xff1b;对于多分类模型&#xff0c;我们将简单介绍Spss中的多分类线性判别分析和多分类逻辑回归的操作步骤下。 本题按水…

利用abapGit的离线模式导出、导入开发对象

1. 背景 abapGit是为ABAP服务器开发的开源Git客户端&#xff0c;用于在ABAP系统之间导入和导出ABAP对象。 使用abapGit&#xff0c;可以将ABAP对象从任何系统导出到另一个系统&#xff0c;通常是从本地系统导出到云&#xff0c;或者从一个云系统导出到另一个云系统。 当然从…

【Linux命令详解 | ls命令】Linux系统中用于列出目录内容的命令

文章标题 简介一&#xff0c;参数列表二&#xff0c;使用介绍1. 基本使用2. 列出文件详细信息3. 列出所有文件4. 以易读的方式显示文件大小5. 只查看目录信息6. 递归列出所有子目录下的文件7. 按文件最后修改时间排序8. 反向排序9. 按文件大小排序10. 显示文件的inode号11. 在文…

Flutter Flar动画实战

在Flare动面出现之前,Flare动画大体可以分为使用AnimationController控制的基础动画以及使用Hero的转场动画,如果遇到一些复杂的场景,使用这些动画方案实现起来还是有难度的。不过,随着Flutter开始支持Flare矢量动面,Flutter的动画开发也变得越来越简单。事实上,Flare动画…

Grafana集成prometheus(3.Grafana添加promethus数据)

添加数据库 选择Connections -> Datasources&#xff0c;点击Add New data source&#xff0c;填写Promitheus Server Url,点击 save & test完成配置 添加DashBorad 选择prometheus数据库选择code填入对应的查询公式(监控公式参考Prometheus监控公式)修改面板名称Ti…

【ASP.NET MVC】使用动软(五)(13)

一、问题 前文完成的用户登录后的首页如下&#xff1a; 后续账单管理、人员管理等功能页面都有相同的头部&#xff0c;左边和下边&#xff0c;唯一不同的右边内容部分&#xff0c;所以要解决重复设计的问题。 二、解决方法——使用布局页 在Views上右键添加新建项&#xff…

【Verilog/D8】

2023年8月5日 HDBits/Cs450/counter 2bc状态机异步复位noteHDBits/Cs450/history shiftHDBits/Cs450/gshare HDBits/Cs450/counter 2bc状态机 Cs450/counter 2bc LSB最低有效位 module top_module(input clk,input areset,input train_valid,input train_taken,output reg[1…

git merge 和rebase区别

Merge the incoming changes into the current branch 找到两个分支的祖先 commit&#xff0c;然后将公共分支最新版合并到自己的分支&#xff0c;形成一个新的 commit 提交&#xff0c;用图表示如下。 Rebase the current branch on top of the incoming Rebase 则是重新基于…

RichTextBox基本用法

作用&#xff1a;富文本编辑器&#xff0c;支持多种文本展示 常用属性&#xff1a; 允许显示多行 自动换行 展示滚动条 ScrollBars属性值&#xff1a; 1、Both&#xff1a;只有当文本超过RichTextBox的宽度或长度时&#xff0c;才显示水平滚动条或垂直滚动条&#xff0c;或两…

传染病学模型 | Python实现基于使用受控SIR模型分析SARS-CoV-2疫情

效果一览 文章概述 传染病学模型 | Python实现基于使用受控 SIR 模型分析 SARS-CoV-2 疫情 源码设计 import jax.numpy as np import

Mac与windows传文件(超过4G且速度超快,非共享)

MAC与Windows文件互传 背景 尝试了网上的一些方法&#xff0c;诸如设置共享文件夹方法等&#xff0c;但是实际使用中感觉效果一般&#xff0c;对于一些小的文件共同编辑速度还可以。但是在备份或者传递一些较大文件或者很多细小文件的时候就有点捉襟见肘了。制作了一个MAC可读…

O3DE的Pass

Pass介绍 Pass是具有输入和输出的渲染过程。 在最终渲染帧中看到的每个细节都是通过一系列Pass&#xff08;前一个Pass的输出是下一个Pass的输入&#xff09;计算出来的。Pass可以生成图像&#xff08;作为纹理、缓冲区或渲染目标&#xff09;。每个图像都包含关于场景的特定…